Click here to Skip to main content
15,891,184 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: 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 
GeneralRe: Is it my fault? Pin
PIEBALDconsult17-May-18 14:42
mvePIEBALDconsult17-May-18 14:42 
GeneralRe: Is it my fault? Pin
Jon McKee17-May-18 15:16
professionalJon McKee17-May-18 15:16 
GeneralRe: Is it my fault? Pin
PIEBALDconsult21-May-18 14:11
mvePIEBALDconsult21-May-18 14:11 
Well, perhaps "bug" was over-stating my opinion a bit, perhaps "poorly-developed" is a better term, and as I stated in my edit -- searching for a parameter by name (and probably members of other collections as well) is a code smell. Best to avoid it. In many cases, the developer will know what's in a collection. This is true of the program I was working on -- I know the parameter is in there, I even know that it's at index 0, so why search for it by name?

BUT, I write a lot of library/framework code that others might use (yeah, as if), so I need to keep "lesser developers" in mind. Big Grin | :-D

As luck would have it, I was just re-reading a "List of Principles" of Programming Languages and saw this:

"Localized Cost: Users should only pay for what they use; avoid distributed costs." -- MacLennan, 1987

I would apply this to the current discussion as: "Programs which call GetParameter only when the parameter is known to exist should not have to pay for the double-checking that would benefit only other programs."

Is my code still violating that Principle? Yes. Because my GetParameter function tries to be provider-neutral, it has protection against calls that return NULL (e.g. Oracle) -- a program that uses SQL Server will still be paying that cost with no benefit to itself. However, the test for NULL is much less than the double-search.
GeneralRe: Is it my fault? Pin
Jon McKee22-May-18 13:54
professionalJon McKee22-May-18 13:54 
GeneralRe: Is it my fault? Pin
Mark Smeltzer23-May-18 6:08
Mark Smeltzer23-May-18 6:08 
GeneralRe: Is it my fault? Pin
Richard Deeming23-May-18 7:02
mveRichard Deeming23-May-18 7:02 
GeneralRe: Is it my fault? Pin
Mark Smeltzer23-May-18 7:18
Mark Smeltzer23-May-18 7:18 
GeneralRecursion in SQL Pin
dan!sh 14-May-18 1:50
professional dan!sh 14-May-18 1:50 
GeneralRe: Recursion in SQL Pin
Jörgen Andersson14-May-18 3:27
professionalJörgen Andersson14-May-18 3:27 
GeneralRe: Recursion in SQL Pin
Richard Deeming14-May-18 8:50
mveRichard Deeming14-May-18 8:50 
GeneralRe: Recursion in SQL Pin
Super Lloyd14-May-18 16:52
Super Lloyd14-May-18 16:52 
GeneralRe: Recursion in SQL Pin
dan!sh 14-May-18 19:36
professional dan!sh 14-May-18 19:36 
GeneralRe: Recursion in SQL Pin
Super Lloyd14-May-18 21:18
Super Lloyd14-May-18 21:18 
GeneralRe: Recursion in SQL Pin
GuyThiebaut14-May-18 20:45
professionalGuyThiebaut14-May-18 20:45 
GeneralRe: Recursion in SQL Pin
DaveAuld19-May-18 21:36
professionalDaveAuld19-May-18 21:36 
GeneralRe: Recursion in SQL Pin
David A. Gray25-Jun-18 11:26
David A. Gray25-Jun-18 11:26 
GeneralTime Stamps Rendered by CMD.exe Pin
David A. Gray13-May-18 19:43
David A. Gray13-May-18 19:43 
GeneralRe: Time Stamps Rendered by CMD.exe Pin
Jochen Arndt13-May-18 20:56
professionalJochen Arndt13-May-18 20:56 
GeneralRe: Time Stamps Rendered by CMD.exe Pin
David A. Gray14-May-18 10:17
David A. Gray14-May-18 10:17 
GeneralRe: Time Stamps Rendered by CMD.exe Pin
Jochen Arndt14-May-18 12:12
professionalJochen Arndt14-May-18 12:12 

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.