Click here to Skip to main content
15,909,566 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: Thats why i hate c++ Pin
harold aptroot26-Apr-12 9:02
harold aptroot26-Apr-12 9:02 
GeneralRe: Thats why i hate c++ Pin
Stefan_Lang27-Apr-12 4:34
Stefan_Lang27-Apr-12 4:34 
GeneralRe: Thats why i hate c++ Pin
Stephen Dycus27-Apr-12 5:55
professionalStephen Dycus27-Apr-12 5:55 
GeneralRe: Thats why i hate c++ Pin
CDP180227-Apr-12 8:42
CDP180227-Apr-12 8:42 
GeneralRe: Thats why i hate c++ Pin
Alan Balkany27-Apr-12 4:44
Alan Balkany27-Apr-12 4:44 
GeneralRe: Thats why i hate c++ Pin
CDP180227-Apr-12 8:56
CDP180227-Apr-12 8:56 
GeneralRe: Thats why i hate c++ Pin
Alan Balkany27-Apr-12 9:08
Alan Balkany27-Apr-12 9:08 
GeneralRe: Thats why i hate c++ Pin
CDP180227-Apr-12 10:23
CDP180227-Apr-12 10:23 
1. C++ really does not have a monopoly on stupid error messages. No matter where they turn up, I look them up in MSDN only twice: For the first and the last time. After that I know what they are about.

2. Really? What kind of errors are these? I can think of many cases where the compiler cannot distinguish between an error and intention and must assume that you know what you are doing. By design that's more the case for C++. You can't have both freedom and safeguards against unintentional mistakes at once, but that's a matter of preferences and not really a flaw.

3. I used to be quite capable to supply those myself quite easily with my own exception classes and error logging. It was not really hard to write an exception class, stuff it into a library and consequently use it.

4. Never had any problems with that. I came from assembly programming and was used to having no automatic checks at runtime. Instead of testing array bounds I usually preferred to ensure that the code to calculate the pointers to the item could not violate the bounds. Often by simple means like an assembly macro. Or by design, like using a byte as index for arrays with 256 items. Simple, safe, costs nothing Smile | :) Another way would be to code in a way that must lead to an exception unless everything is correct. 90% of all errors are avoidable, like forgetting to check for null pointers at the proper locations. If it is ensured that an exception will be raised, then those locations should be found during testing and then eliminated forever. This works very well for me. I have one recent web application that now has been running for 18 months without a single failed job.

5. By my experience thats true for every language and library, it's just the scenarios in which those errors occur that change. My best defense against that (also in managed languages) is to keep the code as simple and straightforward as possible. No design for design's sake. No heaping one framework upon another. And, of course, a layer where no error gets past without being recorded, preferranly with as much information as possible. In a way I have turned every operation of the application into a unit test. A transparent design, a few practices and monitoring your application is all that is needed.
At least artificial intelligence already is superior to natural stupidity



GeneralRe: Thats why i hate c++ Pin
Stephen Dycus27-Apr-12 10:56
professionalStephen Dycus27-Apr-12 10:56 
GeneralRe: Thats why i hate c++ Pin
Rob Grainger26-Apr-12 23:20
Rob Grainger26-Apr-12 23:20 
GeneralRe: Thats why i hate c++ Pin
krsmichael27-Apr-12 4:00
krsmichael27-Apr-12 4:00 
GeneralRe: Thats why i hate c++ Pin
Vasily Tserekh27-Apr-12 5:14
Vasily Tserekh27-Apr-12 5:14 
GeneralRe: Thats why i hate c++ Pin
krsmichael27-Apr-12 3:53
krsmichael27-Apr-12 3:53 
GeneralRe: Thats why i hate c++ Pin
Vasily Tserekh27-Apr-12 5:30
Vasily Tserekh27-Apr-12 5:30 
GeneralRe: Thats why i hate c++ Pin
krsmichael27-Apr-12 6:46
krsmichael27-Apr-12 6:46 
GeneralRe: Thats why i hate c++ Pin
krsmichael27-Apr-12 6:50
krsmichael27-Apr-12 6:50 
GeneralRe: Thats why i hate c++ Pin
Vasily Tserekh27-Apr-12 7:33
Vasily Tserekh27-Apr-12 7:33 
GeneralRe: Thats why i hate c++ Pin
CDP180227-Apr-12 8:19
CDP180227-Apr-12 8:19 
GeneralRe: Thats why i hate c++ Pin
krsmichael27-Apr-12 10:07
krsmichael27-Apr-12 10:07 
GeneralRe: Thats why i hate c++ Pin
Gerry Schmitz27-Apr-12 12:02
mveGerry Schmitz27-Apr-12 12:02 
GeneralRe: Thats why i hate c++ Pin
krsmichael27-Apr-12 14:34
krsmichael27-Apr-12 14:34 
GeneralRe: Thats why i hate c++ Pin
CDP180227-Apr-12 7:32
CDP180227-Apr-12 7:32 
GeneralRe: Thats why i hate c++ Pin
Vasily Tserekh27-Apr-12 7:51
Vasily Tserekh27-Apr-12 7:51 
GeneralRe: Thats why i hate c++ Pin
CDP180227-Apr-12 8:36
CDP180227-Apr-12 8:36 
GeneralRe: Thats why i hate c++ Pin
Al_Brown29-Apr-12 20:59
Al_Brown29-Apr-12 20:59 

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.