Click here to Skip to main content
14,486,715 members

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, embarrassing 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.

 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Greg Utas9-Mar-20 1:24
professionalGreg Utas9-Mar-20 1:24 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Stefan_Lang8-Mar-20 23:29
mveStefan_Lang8-Mar-20 23:29 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Greg Utas9-Mar-20 1:34
professionalGreg Utas9-Mar-20 1:34 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Member 91670578-Mar-20 22:18
MemberMember 91670578-Mar-20 22:18 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
John R. Shaw26-Mar-20 19:52
MemberJohn R. Shaw26-Mar-20 19:52 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Nelek26-Mar-20 23:31
protectorNelek26-Mar-20 23:31 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Member 798912229-Mar-20 12:26
MemberMember 798912229-Mar-20 12:26 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Stefan_Lang8-Mar-20 23:51
mveStefan_Lang8-Mar-20 23:51 
That's one of the problems that don't fit modern coding standards: When your (valid) syntax doesn't properly express what it does, then your choice of syntax is bad. In your example, it would be better to use some function like
template <class T> T* makeCArrayOfLength(size_t length) { return new T[length]; }

whereas the functionality you invoked should be represented by
template <class T> T* makeObjectFromValue(T const& value) { return new T(value); }


That syntax not only will give you much better insight on what you are doing, it might also cause compiler warnings or errors when used incorrectly.

Of course, it's a little more effort to write
_TCHAR *buffer = makeCArrayOfLength<_TCHAR>(buffersize);

But that effort pays off in the long run.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

GeneralRe: Lets' change things up; how about the inept and stupid Pin
Gary R. Wheeler9-Mar-20 12:36
MemberGary R. Wheeler9-Mar-20 12:36 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Stefan_Lang9-Mar-20 21:32
mveStefan_Lang9-Mar-20 21:32 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Gary R. Wheeler10-Mar-20 6:59
MemberGary R. Wheeler10-Mar-20 6:59 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Nelek26-Mar-20 23:29
protectorNelek26-Mar-20 23:29 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Richard MacCutchan26-Mar-20 23:43
mveRichard MacCutchan26-Mar-20 23:43 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Marc Clifton27-Mar-20 8:16
mvaMarc Clifton27-Mar-20 8:16 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Greg Utas27-Mar-20 11:01
professionalGreg Utas27-Mar-20 11:01 
GeneralWonderful: For those of you that want to teach yourself more advanced CS concepts Pin
honey the codewitch26-Feb-20 9:44
mvahoney the codewitch26-Feb-20 9:44 
GeneralRe: Wonderful: For those of you that want to teach yourself more advanced CS concepts Pin
Amarnath S26-Feb-20 13:32
professionalAmarnath S26-Feb-20 13:32 
GeneralRe: Wonderful: For those of you that want to teach yourself more advanced CS concepts Pin
crudecodeyogi27-Feb-20 8:40
Membercrudecodeyogi27-Feb-20 8:40 
GeneralRe: Wonderful: For those of you that want to teach yourself more advanced CS concepts Pin
John R. Shaw26-Mar-20 20:02
MemberJohn R. Shaw26-Mar-20 20:02 
GeneralRe: Wonderful: For those of you that want to teach yourself more advanced CS concepts Pin
honey the codewitch26-Mar-20 20:16
mvahoney the codewitch26-Mar-20 20:16 
GeneralThis Definitely Falls into the Wonderful Camp Pin
David A. Gray9-Feb-20 11:14
MemberDavid A. Gray9-Feb-20 11:14 
GeneralRe: This Definitely Falls into the Wonderful Camp Pin
Randor 10-Feb-20 12:33
professional Randor 10-Feb-20 12:33 
GeneralRe: This Definitely Falls into the Wonderful Camp Pin
David A. Gray11-Feb-20 10:33
MemberDavid A. Gray11-Feb-20 10:33 
GeneralRe: This Definitely Falls into the Wonderful Camp Pin
Randor 11-Feb-20 12:40
professional Randor 11-Feb-20 12:40 
GeneralVisual Studio 2019 and the Weird, Wonderful Nonbreaking Space Pin
David A. Gray8-Feb-20 11:33
MemberDavid A. Gray8-Feb-20 11:33 

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

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