- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Beautiful. This is a classic example of how to properly write unmaintainable code:
http://mindprod.com/jgloss/unmainprinciples.html
They've followed the miscellaneous techniques, to a tee:
<FONT color=#800080>http://mindprod.com/jgloss/unmainmisc.html</FONT>
<FONT color=#800080>
Job well done...[Y]
Admin
I've just scanned 101 comments, and I can't believe that no one has pointed out that this is standard programming practice for platform agnostic assembler.
c'mon. I know you are all C/C++/Java/C# weenies, but hasn't anyone here been coding for more than 20 years?
Obviously, if you use a platform with bit-mapped booleans (like the PDP architecture C maps), you get True=1. If you use a platform with word-mapped booleans (like the 8086 family), you get True = -1. If you want your code to work on both platforms, you don't depend on compiler values for true/false.
That doesn't just apply to assembler. Anyone who was interested in the 80's would have heard about languages where the True/False values were indeterminate or had changed values.
sheesh. I've just pulled a copy 'Writing Solid Code' (1993, Stephen Maguire) off the shelf. He knows what True and False are, but even so, he doesn't include booleans in his list of portable types.
I know the world has changed. We are all C+++ programmers now, and the language definition is set in cement. Still, I would have thought that along with laughs, a little acknowledgment that the code sample is perhaps out-of-date as well as unjustified.
(david)
Admin
Congratulations. You are the first. This was a great opportunity for you to politely make your point. You did make your point.
I do not use the languages mentioned and have not for a while. I have been coding for over twenty years.
All of your points are valid as far as they go. The WTF was not that true and false values were defined. It is that they were duplicated n times.
Sincerely,
Gene Wirchenko
Admin
I don't think duplicating the booleans was a WTF. I'm not defending it in theoretical or stylistic terms, but if you know how enterprise-class products are constructed, it is one of the lesser evils.
Typically a huge amount of code is built at one time, and because of market pressures, not fully tested. Then, over a period of years, layers of modifications or configuration options or interfaces to new modules are added, often by new, possibly less skilled, development teams. In practice, a new build for each customer is riskier than turning off configuration options with globals. The application grows by accretion, and no one person would know what it does. An architecture like that cries out for scaffolding, so what we're seeing may be part of an integration testing framework. Personally, I'd always use database tables for stuff like that instead of the booleans, but I'm not at all surprised to see something that does not help the production system.
BTW, in the Oracle world there are 3 values for booleans (sort of) - the variables can be null. Formally, NULL only means the absence of value, but you have to account for it in your code.
Admin
I guess I mistook the tone of this forum. Apparently, it's alright to insult /other/ programmers,
"This is either fake or however wrote this code was bored and trying to look busy, or maybe they just smoke a lot of crack"
and professions,
"Wait, maybe he's a former lawyer"
use use crudity in wildly elliptical comments,
"Even though physical punishment is forbidden in todays schools and universities I reckon there are teachers and professors who would beat the s?*t out of their students for doing something stupid like this!"
but similiar characterisations when applied to contributers /here/ are verbotim.
Thanks for the heads-up.
(david)
Admin
You're looking for a slap upside the head, you fucking lazy crack smoking lawyer bastard.
<font size="1">(Joke, as though it needed mentioning, but you never can tell with crack smoking lawyers)</font>
Simon
Admin
I used a hardware system that had a '0' for TRUE, the only reason why I could think someone would do this evil thing! This program obviously didn't need that, it reads like "captain obvious"
Admin
This is Cobol, classic Cobol re-written into Java. I see this sort of thing all the time. Old greybeards unable to re-arrange their neural nets to write stuff any different to how they've been doing it for the last 20 years. Sad really...