- 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
Were it written in Cobol, 88 levels would have been much more elegant. :)
Admin
Seriously... You can do the things you would use an actual bitmask for... instead of assigning conditions random ass integer values Windows API error style...
By god, I think I'll use this method from now on then.
Admin
There are 3 kinds of people in the world: Those who can count, and those who can't.
Admin
I didn't check over the numbers to see if any turn into the same value, but boy would that be a tough bug to figure out if they did!
Admin
And isn't 0... considered octal, while 1... is considered decimal? :)
Admin
Sheesh. Of course you can.
A binary AND can be used to check for a flag. 01100 AND 01000 = 01000, which is logically true. If the bit isn't set, the result is 0 which logically false.
A binary OR can be used to add up flags: 01 OR 10 = 11.
Admin
What an idiot. the easiest way to set the values would be to say:
matchpattern = (int)((char)(int)hasLastName + (char)(int)hasDob + (char)(int)hasFirstName + (char)(int)hasEmail + (char)(int)hasRefNo + (char)(int)hasTelNo + (char)(int)hasAddr);
Admin
Fer chrissakes, write a HELPER FUNCTION to do that.
Make it common and you NEVER HAVE TO WRITE IT AGAIN.
Admin
Yes, and it's only about 10000x less efficient to do it that way... very nice indeed.
Admin
shut up
Admin
Except, the first one is in octal ...
Admin
Of course you can do it with a binary bit flipper, integerflagholder & (1 << positiontotest)
That was you can do it in 2 CPU cycles, rather than hundreds.
Admin
Well then, it also means that each "special case" is very much separated from others. Makes no sense to me. Who says that the actual business logic can't be "fall thru" (with possibly a few while/goto sequences) rather than "switch case"?
I suppose the actual business logic for this case is the total opposite of DRY coding. It tends to get like that when there are OVER 9000(!!!!) socially excluded coders working on a single project.
Just my gigazillion cents.