- 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
You're assuming here that the requirements document is complete, accurate, and up-to-date.
Yes, in a perfect world the requirements document would have started out describing the requirements 100% accurately, and every change made to the system since would have begun by updating the requirements document.
But in a perfect world, the code would be clear, concise, and bug-free.
So, hmm, as the code apparently has problems, it would seem that we are NOT living in a perfect world. So why do you assume that there even is a requirements document? Never mind supposing that it is worth the time it would take to dust off the cover and peel the molding pages apart?
Admin
Have you?
Admin
Maybe I'm getting jaded, but this code doesn't look all that bad to me. I think I pretty well understood it on a first reading. The IF's are all nicely laid out one after the other. As others have noted, even with nothing to go on but this one function, it's pretty obvious that this is from a program to manage loading of a Dash 8 aircraft.
Yes, the function name is stupid. I'm not sure if the variables with names like "Frame500" are referring to field number 500 on an input frame object, in which case that's a really dumb name, or if this is Dash 8 airframe style 500, etc, in which case they would be very good names. "pax" is pretty obviously an abbreviation of "passengers", and "loadtot" et al aren't that tough to guess.
All told I'd say this is a moderately well written module. If this is the worst you have to deal with, you don't want to apply for a job at my company.
Admin
It's like an 8-track for video images. Except that it only has one track.
Admin
Oh. Like a kinetoscope?
Admin
Admin
Admin
Our marketdroids are always begging for the app to be "more engaging" and "responsive to the user", so let's put those empty else clauses to work shall we?
Add in a bunch more self-esteem-building affirmations, together with the requisite number of cartoons and colorful animations to keep that short attention span refocused, and I think we're good!
Besides, we all know the more times we make the user click to finish their task, the less they perceive the slowness of the system.
Admin
Admin
Exactly. If you want to do a re-write of an archaic, crazy app like this, you almost definitely don't want it to run like the current app, at least in significant edge cases.
Admin
I lol'd.
Admin
We've been telling you for a quarter century: you can't rely on MS-based software. Not when it really matters. And, with the possible exception of luser desktops, it usually matters.
When 154 people die because an "ancillary" system was running WinBlows (http://www.networkworld.com/news/2010/082310-trojan-blamed-for-spanish-air.html?hpg1=bn) it's time to start lining people up for execution. And I don't mean the multithreaded kind either. Seriously! It's either premeditated murder or capital negligence. No more Mr. Nice Guy!
Admin
Admin
Admin
Admin
I really wanted to believe this. But I've been maintaining an app written in ASP and Access, and I can categorically say, they are terrible.
Admin
Remind me never to take you to the La Brea tar pits.
Admin
Yes, except, get this, it hooks up to your TV! No flickering light shining through acetate film!
Admin
If "nor never" = always Then MsgBox "FAIL !!!!!", vbOKOnly Else End If
Admin
I for one am glad that I never had to debug software in the long-lost language of the Romans.
Admin
The answers are 37-seater, no, FILE NOT FOUND.
Admin
Thanks to MS Access's obfuscation wizard!
Admin
Actually this code works great on embedded file systems with no file system.
Admin
Admin
TRWTF is yet another language without a while loop.
Admin
Admin
I think evilspoons was indicating that you should gather new requirements ( at least that is how I read it.
However, gather new requirements is never easy. Gathering "updated" requirements is almost always impossible. User's will invariably say "Just make it work like the old one did". They do not want to spend hours in meeting, talking about the way they work. If you try to explain that you cannot make sense of what the old software was doing, then they do not trust you. And I would have to say they are partly correct. If you cannot trace old code, even if it leads to a dead branch ( never drops in this loop ), then I would not entirely trust you either.
Admin
Assuming that's Java rather than some crazy hybrid language invented just to troll TDWTF forums (which wouldn't actually surprise me), that's not an assignment, that's a compile-time error. Unlike C, Java requires you to compare assignments involving non-boolean values to 0 explicitly if you want to use them in an if condition.
Admin
Admin
I love it when people come in and want to rewrite Airline apps. That noice I hear when their enthusiasm pops is truly heart warming.
Admin
I think everybody's missing something. Sure, it happens to be in VBA ... which is slightly suspicious in and of itself. The main points to note are:
696 functions called Command1 .. Command 696
No function parameters; just globals
Every "if" lovingly paired with an "else"
Doesn't that sound like generated code to you? It does to me. I strongly suspect there is some godawful "design" document thrown together in an Excel spreadsheet, with a bonkers in-house code generator, behind this.
Still, at least that way there's a design...
Admin
Nope. I guess it would if I weren't familiar with VB; but actually it sounds like lazy VB programming - which is to say, most of the VB programming I've seen.
When you design a form in VB, it provides a default name for each control. The default name is the type of control followed by a sequence number. Many programmers don't bother to change the default name, even though you almost always should. The method names are derived from the control name. (This snippet is showing the code behind a command button, btw.)
VB also is designed to be usable by people who probably never learned the reasons that globals are inferior to parameter-passing; most beginners I know would rather use globals (for exactly the reasons they should want to avoid them).
The obsessive use of Else just looks like an idiosyncratic coding style to me.
Admin
Maybe this is the real reason Qantas (or more accurately Qantaslink) grounded 5 of its Dash 8 fleet..... The landing gear can't handle it when the AFT compartment is not empty
http://au.news.yahoo.com/a/-/latest/7800735/qantas-grounds-planes-flights-cancelled/
Admin
The article you posted didn't even mention the OS. Fail.
Admin
Trust me... I've been there, done that -- and ran away screaming! Truly a "legacy code" nightmare.
Admin
The code may not be pretty, but I'd leave it alone. I guarantee that the users care more about the behavior of the app (however screwy) remaining the same than they do about it being "improved". And they don't care at all about the elegance of the code.
Not only that, it's almost a certainty that this app encodes some complex set of business rules that the author will miss when he rewrites it. And nobody wants to be the guy who broke the mission-critical cargo loading app.
If the engineer who submitted this wants to make a real difference, he'd spend his time writing a robust set of automated tests for the existing code.
Admin
Admin
Exactly. I once spent 2 months unpicking a previous contractors mess, carefully mapping out what each method did, and called.
Ye gods, it was awful and one day i might even write it up for here, macros nested within macros (It was An Access project BTW), helpfully hidden queries, every single (non-macro) line of code in the Main form code behind, functions in textboxes on the form. The front end was over 300 MB in size, and took 10 minutes to load, due to bunch of Dlookups, that were 99% useless to the user. The beautiful thing about that project was that i had to race against time as the back-end was rapidly approaching Access's 2GB file size limit.
Admin
In VB and VBA the same operator is used for both. You have to look at the whole statement to determine what the expression actually means.
Admin
Admin
Yes, you're right. People who do development related to systems that can kill people when they malfunction (like aircraft) should definitely play the petty-amateur-lawyer, it's-not-in-the-requirements blame game instead of doing the job right the first time. It's endearing and makes them lots of friends.
Admin
You said Winblows on TDWTF, which means you're either a troll or a spoof. You made me laugh, so I call spoof. What do I win?
Admin
No, the problem is supercilious cliquey programmers who think a hammer is a spoon, and feel threatened by it. You might as well criticise Polyfilla (Spackle) because you don't need to be a master plasterer to smooth over a crack with it. 98% of all VB/VBA code -- official statistics from my bum -- is used in places where if VB did not exist, there would be no automation, rather than a better written piece of code.
Admin
You seem to miss the point..... As thousands have said before me, the code appears to be a ground based sanity check, totally independent of software in the actual plane. A discrepancy in weights might cause some delays while airline staff argued over the best course of action, but that's it. VB is not being used in anything even remotely critical here....
Admin
Admin
You don't think having 696+ functions named like that is a problem??
On one of the few .NET projects I've worked on, our idiot contractor kept naming components the same way, we had things like: SqlCommand1 SqlCommand2 Button4 Label5
I told him continuously not to name components that way, but he would not listen. Finally I used the 'jerk' method and started using flammatory function names like: RidiculouslyNamedComponentNumber4095 WhoKnowsWhatThisDoesNumber4992 SomeKindOfCommand2
I only had to name about 3 methods like that before he finally got a clue & started using descriptive names.
Admin
I bet he'd run into more problems rewriting Command 66, which causes the software to hunt down and kill all the Jedi.
Admin
Totally agree. Yes the code is wtf. But, as pointed out, the logics seems pretty easy to understand for anybody who has an idea of how a commercial aircraft works. Chances are one will fail as a programmer if he does not understand the domain of the client for which he is working. It has nothing to do with computer science or patterns or language. You have to understand your client's domain before you can hope to serve him well. That's a perfect example.
Admin
What's scary is that this software appears to be related to aircraft...
starts digging a bunker to protect against falling planes
Admin
That's procedural programming - not visual programming.
Why would you want to change the default name? DUH, so that you recognise what it means when you read the code.
Why would you want to read the code? DUH, because in your prgramming environment it's not trivially linked to a visual organisational paridigm.
Over 40 years I've seen that XXXX programmers think YYYY is bad XXXX code (insert what ever you love and hate). You like Pascal? FORTRAN is badly written Pascal. You like C/C++/Java/Python? That VBA code is just badly written C/C++/Java/Python.
He didn't even release his objects. His code is toooo verbose/not verbose enough. It's write-only. He used line labels. He used exceptions. He used a COMMON block.
BLAAAAA.
In some languages, it is critically important to use a disciplined naming convention. And in other languages a disciplined naming convention is enforced by the syntax: you don't need any discipline.
And in Access VBA a disciplined naming convention was important for impressing ignorant naive inexperienced programmers who where expert at only one mode of thinking.
Apart from that, not so much.