Click here to Skip to main content

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrasing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
General42 PinprotectorAspDotNetDev5-Dec-12 14:45 
QuestionRe: 42 PinmemberZac Greve5-Dec-12 15:27 
GeneralRe: 42 PinmemberPIEBALDconsult5-Dec-12 16:13 
GeneralRe: 42 PinmemberAdam R Harris11-Dec-12 11:13 
GeneralWould you like to buy an IsNull ? PinmemberPIEBALDconsult5-Dec-12 9:04 
GeneralRe: Would you like to buy an IsNull ? Pinmember d@nish 5-Dec-12 9:22 
GeneralRe: Would you like to buy an IsNull ? PinmemberPIEBALDconsult5-Dec-12 10:31 
GeneralRe: Would you like to buy an IsNull ? PinprotectorAspDotNetDev5-Dec-12 11:07 
GeneralRe: Would you like to buy an IsNull ? PinmemberPIEBALDconsult5-Dec-12 13:10 
GeneralRe: Would you like to buy an IsNull ? Pinmember d@nish 5-Dec-12 22:06 
GeneralRe: Would you like to buy an IsNull ? PinmemberKP Lee5-Dec-12 13:36 
GeneralRe: Would you like to buy an IsNull ? PinmemberPIEBALDconsult5-Dec-12 14:11 
GeneralRe: Would you like to buy an IsNull ? PinmemberJörgen Andersson6-Dec-12 22:12 
GeneralWhy do engineers insist on complexity? PinmemberJoe Woodbury4-Dec-12 8:33 
A few years ago, I was working on some very legacy code that required a temporary array in a function. The array size would never, ever change and could be hard coded.
 
The legacy code:
 
char* pData = new char[4];
//Do stuff
delete[] pData;
 
When I mentioned this recently to a colleague, he said that a smart pointer should have been used. Today that would be:
 
std::unique_ptr<char> pData = new char[4];
//Do stuff
 
Last week, I ran across a web site discussing optimizations that a similar concept, though with more items. Applied to the legacy code, this this "expert's" solution was:
 
std::vector<char> data(4);
//Do stuff
 
Why not just my solution:
 
char data[4];
//Do stuff
 
Have people gotten so accustomed to complexity that they think of only complex solutions?
 
(I have other examples, the second funniest was when someone suggested using a boost function instead of three lines of elementary C code.)
GeneralRe: Why do engineers insist on complexity? PinmemberAndrew Rissing4-Dec-12 9:11 
JokeRe: Why do engineers insist on complexity? PinmemberZac Greve4-Dec-12 9:12 
GeneralRe: Why do engineers insist on complexity? PinmemberChris Meech4-Dec-12 10:10 
GeneralRe: Why do engineers insist on complexity? PinmemberYvesDaoust4-Dec-12 21:57 
GeneralRe: Why do engineers insist on complexity? PinmemberSeattleC++5-Dec-12 8:00 
GeneralRe: Why do engineers insist on complexity? PinmemberFran Porretto5-Dec-12 1:50 
GeneralRe: Why do engineers insist on complexity? PinmemberPSM_300E5-Dec-12 3:16 
GeneralRe: Why do engineers insist on complexity? PinmemberFran Porretto5-Dec-12 3:17 
GeneralRe: Why do engineers insist on complexity? PinmemberPSM_300E5-Dec-12 3:19 
GeneralRe: Why do engineers insist on complexity? PinmemberMark H25-Dec-12 9:13 
GeneralRe: Why do engineers insist on complexity? PinmemberBC @ CV5-Dec-12 6:05 
GeneralRe: Why do engineers insist on complexity? PinmemberSeattleC++5-Dec-12 8:12 
GeneralRe: Why do engineers insist on complexity? PinmemberFran Porretto5-Dec-12 8:31 
GeneralRe: Why do engineers insist on complexity? Pinmembersatovey5-Dec-12 12:16 
GeneralRe: Why do engineers insist on complexity? PinmemberFran Porretto6-Dec-12 1:28 
GeneralRe: Why do engineers insist on complexity? Pinmember0bx6-Dec-12 8:00 
GeneralRe: Why do engineers insist on complexity? PinmemberFrans_551295-Dec-12 2:04 
GeneralRe: Why do engineers insist on complexity? PinmemberBobJanova5-Dec-12 2:22 
GeneralRe: Why do engineers insist on complexity? PinmemberRoger1655-Dec-12 3:26 
GeneralRe: Why do engineers insist on complexity? PinmemberRafagaX5-Dec-12 6:03 
GeneralRe: Why do engineers insist on complexity? PinmemberMember 45591065-Dec-12 7:00 
GeneralRe: Why do engineers insist on complexity? Pinmemberpatbob5-Dec-12 7:04 
GeneralRe: Why do engineers insist on complexity? PinmemberFreak305-Dec-12 23:45 
GeneralRe: Why do engineers insist on complexity? PinmemberNemanja Trifunovic8-Dec-12 4:08 
GeneralLocalization is great PinmemberBernhard Hiller29-Nov-12 22:53 
GeneralRe: Localization is great PinmemberZac Greve30-Nov-12 5:13 
GeneralTry/catch block... PinmemberProgramFOX18-Nov-12 4:28 
GeneralRe: Try/catch block... PinmemberRugbyLeague18-Nov-12 4:57 
GeneralRe: Try/catch block... PinmemberProgramFOX18-Nov-12 4:59 
GeneralRe: Try/catch block... PinmemberVitorHugoGarcia21-Nov-12 4:31 
GeneralRe: Try/catch block... PinmemberMark Wallace19-Nov-12 2:19 
GeneralRe: Try/catch block... PinmemberProgramFOX20-Nov-12 7:26 
GeneralRe: Try/catch block... PinmemberZac Greve20-Nov-12 12:45 
JokeRe: Try/catch block... PinmemberBernhard Hiller19-Nov-12 23:56 
GeneralRe: Try/catch block... PinmemberRichard Deeming20-Nov-12 2:37 
GeneralRe: Try/catch block... PinmemberBernhard Hiller20-Nov-12 5:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 31 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid