Click here to Skip to main content
15,911,789 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.

 
AnswerRe: C/C++ or C#? [modified] Pin
Thomas Weller2-Nov-08 20:13
Thomas Weller2-Nov-08 20:13 
GeneralRe: C/C++ or C#? Pin
Nagy Vilmos2-Nov-08 22:28
professionalNagy Vilmos2-Nov-08 22:28 
GeneralRe: C/C++ or C#? Pin
PIEBALDconsult3-Nov-08 4:03
mvePIEBALDconsult3-Nov-08 4:03 
GeneralRe: C/C++ or C#? Pin
Nemanja Trifunovic3-Nov-08 8:24
Nemanja Trifunovic3-Nov-08 8:24 
GeneralRe: C/C++ or C#? Pin
Thomas Weller3-Nov-08 8:48
Thomas Weller3-Nov-08 8:48 
GeneralRe: C/C++ or C#? Pin
Nemanja Trifunovic3-Nov-08 9:11
Nemanja Trifunovic3-Nov-08 9:11 
GeneralRe: C/C++ or C#? Pin
Thomas Weller3-Nov-08 9:35
Thomas Weller3-Nov-08 9:35 
GeneralRe: C/C++ or C#? Pin
Nemanja Trifunovic3-Nov-08 9:58
Nemanja Trifunovic3-Nov-08 9:58 
Thomas Weller wrote:
This is a quite good definition of what Dispose pattern is in C#...


It even better describes the RAII idiom in C++ Smile | :)


Thomas Weller wrote:
It is hard to follow if it gets lengthy


It does, but at least it is cleanly separated: the "normal path" is in the if part, and the error handling in the else part. With the "pipe" model, both code paths interrupt each other and thats really messy and error prone.
Thomas Weller wrote:
Error probability increases dramatically with every level of nesting - especially when it comes to maintenance.


How come? There is no copy-paste code and if something needs to be changed, it needs to be changed in one place. With the "pipe" model, if you add a new resource allocation, you need to make sure that it is released in each return path.

Thomas Weller wrote:
This sort of coding simply does not well with monitor space. Lines are indented for every nesting level - and soon you have to scroll horizontally only for reading source code!


No argument here, except that most editors have this secret little feature called "line wrapping" Smile | :)


Thomas Weller wrote:
Readability and maintainability issues.


Exactly the same arguments I have for the opposite argument - don't you love programming discussions? Laugh | :laugh:


GeneralRe: C/C++ or C#? Pin
Thomas Weller3-Nov-08 10:08
Thomas Weller3-Nov-08 10:08 
GeneralRe: C/C++ or C#? Pin
Nemanja Trifunovic3-Nov-08 10:28
Nemanja Trifunovic3-Nov-08 10:28 
GeneralRe: C/C++ or C#? Pin
Thomas Weller4-Nov-08 3:19
Thomas Weller4-Nov-08 3:19 
GeneralRe: C/C++ or C#? Pin
Dan Neely3-Nov-08 10:13
Dan Neely3-Nov-08 10:13 
GeneralRe: C/C++ or C#? Pin
Thomas Weller3-Nov-08 10:17
Thomas Weller3-Nov-08 10:17 
GeneralRe: C/C++ or C#? Pin
Nemanja Trifunovic3-Nov-08 10:35
Nemanja Trifunovic3-Nov-08 10:35 
GeneralRe: C/C++ or C#? Pin
Dan Neely4-Nov-08 2:16
Dan Neely4-Nov-08 2:16 
GeneralRe: C/C++ or C#? Pin
Nemanja Trifunovic4-Nov-08 4:29
Nemanja Trifunovic4-Nov-08 4:29 
GeneralRe: C/C++ or C#? Pin
supercat95-Nov-08 6:18
supercat95-Nov-08 6:18 
GeneralRe: C/C++ or C#? Pin
Thomas Weller5-Nov-08 6:48
Thomas Weller5-Nov-08 6:48 
GeneralRe: C/C++ or C#? Pin
Thomas Weller5-Nov-08 6:55
Thomas Weller5-Nov-08 6:55 
GeneralRe: C/C++ or C#? Pin
supercat95-Nov-08 10:17
supercat95-Nov-08 10:17 
GeneralRe: A big if Pin
Paul Conrad2-Nov-08 5:03
professionalPaul Conrad2-Nov-08 5:03 
GeneralRe: A big if Pin
Tom Deketelaere2-Nov-08 23:30
professionalTom Deketelaere2-Nov-08 23:30 
GeneralRe: A big if Pin
Kevin McFarlane5-Nov-08 23:53
Kevin McFarlane5-Nov-08 23:53 
GeneralRe: A big if Pin
Tom Deketelaere6-Nov-08 0:20
professionalTom Deketelaere6-Nov-08 0:20 
GeneralRe: A big if Pin
Kevin McFarlane6-Nov-08 1:00
Kevin McFarlane6-Nov-08 1:00 

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.