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

 
GeneralIs it my fault? Pin
PIEBALDconsult14-May-18 14:31
mvePIEBALDconsult14-May-18 14:31 
GeneralRe: Is it my fault? Pin
Super Lloyd14-May-18 16:51
Super Lloyd14-May-18 16:51 
GeneralRe: Is it my fault? Pin
Jon McKee14-May-18 18:17
professionalJon McKee14-May-18 18:17 
GeneralRe: Is it my fault? Pin
Eddy Vluggen15-May-18 1:01
professionalEddy Vluggen15-May-18 1:01 
GeneralRe: Is it my fault? Pin
Jon McKee15-May-18 8:36
professionalJon McKee15-May-18 8:36 
GeneralRe: Is it my fault? Pin
Eddy Vluggen16-May-18 0:46
professionalEddy Vluggen16-May-18 0:46 
GeneralRe: Is it my fault? Pin
F-ES Sitecore16-May-18 1:21
professionalF-ES Sitecore16-May-18 1:21 
GeneralRe: Is it my fault? Pin
Eddy Vluggen16-May-18 1:39
professionalEddy Vluggen16-May-18 1:39 
F-ES Sitecore wrote:
We're not talking about errors though, an item not existing in a collection (in the specific code we're talking about) is not an error.
It IS if you reference an item in the collection that doesn't exist. Give it a try and you'll see an exception.

F-ES Sitecore wrote:
If a situation is expected to happen you should be coding for it, not using exceptions.
That must be why File.Open doesn't throw any exceptions if you read a non-existing file Roll eyes | :rolleyes:

The idea that one should avoid using exceptions is simply wrong. That's the reason you don't do a check before inserting; you rely on the exception-handling mechanism to handle the exceptional circumstance that there is a clash (or pk-violation, or any other constraint). It is a lot cleaner to handle any exception than it is to do a single check on each constraint, and a lot more efficient.

F-ES Sitecore wrote:
You can assume the item is there and if it isn't catch the exception and add the item in the exception handler which is logically unsound as the scenario where the item doesn't exist is an expected one, and this method is 10x slower.
Whether or not the existence of the item is expected or unexpected is up to the programmer; lots of designs where I can safely assume the item to exist, and where it not existing WOULD be a logical error.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

GeneralRe: Is it my fault? Pin
F-ES Sitecore16-May-18 2:33
professionalF-ES Sitecore16-May-18 2:33 
GeneralRe: Is it my fault? Pin
Eddy Vluggen16-May-18 3:03
professionalEddy Vluggen16-May-18 3:03 
GeneralRe: Is it my fault? Pin
F-ES Sitecore16-May-18 3:28
professionalF-ES Sitecore16-May-18 3:28 
GeneralRe: Is it my fault? Pin
Eddy Vluggen16-May-18 3:56
professionalEddy Vluggen16-May-18 3:56 
GeneralRe: Is it my fault? Pin
F-ES Sitecore16-May-18 4:09
professionalF-ES Sitecore16-May-18 4:09 
GeneralRe: Is it my fault? Pin
Eddy Vluggen16-May-18 10:35
professionalEddy Vluggen16-May-18 10:35 
GeneralRe: Is it my fault? Pin
F-ES Sitecore16-May-18 22:27
professionalF-ES Sitecore16-May-18 22:27 
GeneralRe: Is it my fault? Pin
Eddy Vluggen18-May-18 0:03
professionalEddy Vluggen18-May-18 0:03 
GeneralRe: Is it my fault? Pin
F-ES Sitecore18-May-18 0:10
professionalF-ES Sitecore18-May-18 0:10 
GeneralRe: Is it my fault? Pin
Eddy Vluggen18-May-18 0:16
professionalEddy Vluggen18-May-18 0:16 
GeneralRe: Is it my fault? Pin
Jon McKee17-May-18 18:21
professionalJon McKee17-May-18 18:21 
GeneralRe: Is it my fault? Pin
Eddy Vluggen17-May-18 23:57
professionalEddy Vluggen17-May-18 23:57 
GeneralRe: Is it my fault? Pin
Jon McKee18-May-18 10:13
professionalJon McKee18-May-18 10:13 
GeneralRe: Is it my fault? Pin
Eddy Vluggen18-May-18 13:09
professionalEddy Vluggen18-May-18 13:09 
GeneralRe: Is it my fault? Pin
David A. Gray25-Jun-18 11:19
David A. Gray25-Jun-18 11:19 
GeneralRe: Is it my fault? Pin
PIEBALDconsult16-May-18 17:09
mvePIEBALDconsult16-May-18 17:09 
GeneralRe: Is it my fault? Pin
Jon McKee17-May-18 14:35
professionalJon McKee17-May-18 14:35 

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.