Click here to Skip to main content
16,004,991 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: For loop Pin
Ed.Poore13-Mar-07 2:09
Ed.Poore13-Mar-07 2:09 
GeneralRe: For loop Pin
PIEBALDconsult13-Mar-07 4:19
mvePIEBALDconsult13-Mar-07 4:19 
GeneralRe: For loop Pin
Ed.Poore13-Mar-07 6:20
Ed.Poore13-Mar-07 6:20 
GeneralRe: For loop Pin
Shog913-Mar-07 7:00
sitebuilderShog913-Mar-07 7:00 
GeneralRe: For loop Pin
Ed.Poore13-Mar-07 7:03
Ed.Poore13-Mar-07 7:03 
GeneralRe: For loop Pin
#12313-Mar-07 7:35
#12313-Mar-07 7:35 
GeneralRe: For loop Pin
#12313-Mar-07 7:33
#12313-Mar-07 7:33 
GeneralRe: For loop Pin
Shog913-Mar-07 7:51
sitebuilderShog913-Mar-07 7:51 
You're right - i was just pointing out how even a small change could make terrible code much easier to understand.

In reality (although it'd depend a lot on what i was doing), i'd probably have a good many more constants defined. As the code stands, even if you understand that we're talking about two weeks, there's no indication of why two weeks, rather than, say, three weeks, or a week and three days. Generally, when i'm doing something like this i'll start out by building a set of constants, starting with basic things and building up to program-specific constants (grace_period = weeks(2) or some such).

Again though, it depends what i'm doing. Ideally, a logically-complete block of code works only with a single unit of measure, as this makes it easier to see mistakes when working with it (because i can assume all constants use the same units).



----
...the wind blows over it and it is gone, and its place remembers it no more...

GeneralRe: For loop Pin
#12313-Mar-07 7:59
#12313-Mar-07 7:59 
GeneralRe: For loop Pin
Shog913-Mar-07 8:07
sitebuilderShog913-Mar-07 8:07 
GeneralRe: For loop Pin
#12313-Mar-07 8:31
#12313-Mar-07 8:31 
GeneralRe: For loop Pin
Shog913-Mar-07 8:40
sitebuilderShog913-Mar-07 8:40 
GeneralRe: For loop Pin
#12313-Mar-07 8:49
#12313-Mar-07 8:49 
GeneralRe: For loop Pin
Shog913-Mar-07 9:01
sitebuilderShog913-Mar-07 9:01 
GeneralRe: For loop Pin
#12313-Mar-07 9:05
#12313-Mar-07 9:05 
GeneralRe: For loop Pin
Shog913-Mar-07 9:27
sitebuilderShog913-Mar-07 9:27 
GeneralRe: For loop Pin
#12313-Mar-07 9:33
#12313-Mar-07 9:33 
GeneralRe: For loop Pin
Chris-Kaiser15-Mar-07 12:29
Chris-Kaiser15-Mar-07 12:29 
GeneralRe: For loop Pin
Chris-Kaiser15-Mar-07 12:28
Chris-Kaiser15-Mar-07 12:28 
GeneralRe: For loop Pin
Chris-Kaiser15-Mar-07 12:27
Chris-Kaiser15-Mar-07 12:27 
GeneralRe: For loop Pin
Jörgen Sigvardsson15-Mar-07 13:07
Jörgen Sigvardsson15-Mar-07 13:07 
GeneralRe: For loop Pin
Ed.Poore13-Mar-07 8:00
Ed.Poore13-Mar-07 8:00 
GeneralRe: For loop Pin
#12313-Mar-07 8:25
#12313-Mar-07 8:25 
GeneralRe: For loop Pin
Ed.Poore13-Mar-07 9:10
Ed.Poore13-Mar-07 9:10 
GeneralRe: For loop Pin
#12313-Mar-07 9:19
#12313-Mar-07 9:19 

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.