- 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
Maybe Im not getting a joke here, but hy not just iterate over the 5 objects rather than have a conditional?
Admin
Exactly, you only need 1 line in the Case Statements, then use a WITH block below it.
Some people just don't think in terms of objects... The even bigger question is do all these classes inherit from a common base class?
VB Needs a refactoring tool that shows new coders how to do refactoring, most VB programmers don't even know what refactoring is.
It would be really nice to see how people CORRECT the mistakes found in this site in the most efficient way.
It's great to laugh at the "most rediculous item of the day" but it would even be more interesting for coders starting out to be able to see these fairly common mistakes and learn how to avoid/correct them in highly efficient ways.
Admin
>>Some people just don't think in terms of objects... The even bigger question is do all these classes inherit from a common base class?
That's what I was thinking, was maybe there was some non-inherit reason you couldn't do that in VB, and had to ref the properties directly.
Admin
I love it.
And then you can also re-use Icnt and acheive object re-use. No byte left behind!
It would be interesting to see if the scrubbing/ comparison of the same aleged address field for each case uses the same loop construct with favoring fixed Icnt #..
But stuffing arrays with each field from the record returned by the 6 different sources really gets under my skin. If one wanted a bloated copy of the data fetched they should just create a SOAP object.
Admin
What Marc didnt tell you is that that was his code ;) Only kiddin Marc
Admin
Thanks Ben, as if my 'reputation' is not bad enough.
I have no idea what this guy was thinking, but then you should see his UI :p
I suppose he needed the CASE statement otherwise he'd have ended up running each piece of code 5 times, right? ;) Wait a minute... D'Oh!
Admin
this will never beat of the now former programmer who was able to code such a complex subroutine, with so many nested Ifs (he did not know about elseif or iif) all within a loop (scannind data records storing them in undeclared variables).
It was so intense VB took exceptionally long to compile his project.
Best of all his subroutine started with
ON Error Resume Next
Admin
Isn't it wonderful when people are measued by the number lines of code that they have produced.
Admin
You will be happy to know that this programming style isn't restricted to Basic, isn't restricted to Windows, and isn't restricted to programs running in user mode. Some Linux device drivers aren't even coded by volunteers, some are coded by professionals who work for the device makers. And yet the device works. It's astounding.
What's in a name, in C we have to call it the select-case paradigm, but it still smells the same. What about the name of the product, or me? Sorry, I don't want to be fired.
Admin
This is how I would have done it (in C#). Note: I'm making an assumption that these are all instances of the same class (based on the identical properties and methods).
// create array to hold list of items
SomeClass[] items = new SomeClass[] { ManObj, RETObj, DISObj, AGYObj, LAWObj, LiAgObj };
// loop through items
for (int i = 0; i < items.Length; i++)
{
// get item from array and then call methods, properties, etc.
SomeClass obj = items[i];
obj.GetRecords(CaseNumber, ConnObj);
TxtKeyContact[i] = obj.KeyContact;
TxtAddName[i] = obj.Name;
TxtTelephone[i] = obj.Fax;
.
.
.
}
Simple loop without any messy if or switch-case statements. And if they need to work with a new object, they simply add it to the array.
Kiliman
Admin
There is a group of programmers who code in ASM, and write the most efficient code... at a 2600 meeting someone brought a 15-20 minute graphical presentation on a floppy and ran it on a laptop (years ago)... it was pretty impressive. If anyone knows the name of these programmers or has a link to the presentation I'd like to see it again.
Admin
Demosceners.
Admin
select-case? You're fired! In C, i'd call this construct a for-switch. Language-agnostically, I'd probably call it a loop-switch. How about iterative switch? A "switcheration?"
Admin
I don't know whatever language that's written in, but shouldn't there be some sort of a 'break' statement at the end of each case block? If there IS a break statement in that language, and it's missing, then it means the code above results in the following execution:
START
first pass, exec all blocks starting from 0
second pass, exec all blocks starting from 1
third pass, exec all blocks starting from 2
fourth pass, exec all blocks starting from 3
fifth pass, exec all blocks starting from 4
sixth pass, exec last block only (5)
END
If the language does need a break line, then the code in those blocks are getting executed mutiple times, and it's an even worse WTF.
Still though, I'd love to come upon a situation that requires a breakless select in a for loop. That'd be cool.
Admin
Unless they intended to do it that way in the first place! I doubt they did tho lol....
Admin
With the "txt" prefix of the assignment statements, I suspect that the data is going to an array of textbox controls on a form. As such, we can't really apply the easy fix of converting these separate txt_____ arrays into a single array of user-defined datatypes or objects. If that were the case, then only one assignment statement would be required.
This is a VB WTF code example, so Kilman's suggestion would most likely look a little like this:
Admin
Admin
I feel like being pedantic, so I'm going to say that it would be better to do your for block like this:
for (int i = 0, int j = items.Length; i < j; i++)
That way is a lot faster if you have to do it on a large list.
Admin
Maybe the six objects are written by six developers who bitterly refuse to acknowledge a common ancestor.
VB needs ducktaping.
Admin
Thank god someone pointed this out. Everyone else who posted anything before this should hop on-board the failboat. YOU FAIL.
Admin
xeron, wtf really? :D
Admin
I think there are 2 mistakes:
(1) The programmer doesn't understand object-oriented programming.
(2) The programmer is stupid, why is the FOR and CASE in there anyways?
Probably better is:
Hopefully this way will work (although I don't know because I haven't tested it) However, this is late binding.
Also, I think they should use tabstrips instead of like they do now.
Admin
Admin
This just makes me want to cry.
Admin
Supra shoes are so popular all over the world. Whatever you take on Supra being in the Supra Skytop Shoes market. Now Supra Strapped Shoes also very popular attention. It is nice that they actually took the time to make Supra Skate Shoes that work well. Supra shoes is a brand that has been inspired, designed and marketed by passionate individuals. We have brought to you the fullest selection of Supra footwear at cheapest price. Overload Skateshop carries a wide range of Supra Shoes to fit your 9-stair kickflips.
Admin
I had no idea.
Wait, a bot? HOW DID YOU GET PAST THE CAPTCHA?!
Admin
One better;
// loop through items for (int i = 0; i < items.Length; i++) { // get item from array and then call methods, properties, etc. doStuffOnItem(items[i]); }
Admin
oh good you got this far, now turn it into a state pattern.
:o)