- 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
Re "what the $#@~! are they?"
but... it's all in the comments! Why, it's "x,y locations of pumps and valves"
Admin
//Create comment
Ok, this doesn't look optimal.
Admin
//Here,are,all,the,comments //in,no,particular,order
Admin
Yep. I can see where this is going: // Create all variables int prbx1, prbx2, prbx3, prbx4, prbx5, prbx6, prby1, prby2, prby3, prby4, prby5, prby6, prbx7, prby7; ...
if (prbx1 > prby6)
What's the problem? It compiles fine. I created the variables, didn't I?
Admin
I remember doing a directed study, which basically evolved into a translation of a program written by a guy who--although he was in the CS department--probably would have rather been in Mathematics. Why did he need it translated? Because he could no longer find a distribution of the ancient FORTRAN compiler he was using. I hit the school library for reference materials, and when I cracked the book I found a used punch-card functioning as a bookmark. This was the first sign that something was wrong.
Long story short, I ended up tweaking a converter tool for a younger version of FORTRAN, and there was lots of generated code like this.
Admin
Alex Pompadilililimous - Last week (or the week before) I complained about the timeliness of your postings. I retract that comment; thank you for your promptness this week.
Admin
I've seen stuff like that so many times it is not even funny. Now where did I put that hard liquor?
Admin
Nice touch that they even spelled "gauge" wrong as a variable name!
Admin
Ah yes, the "every character is precious" school of variable naming. I once saw a program by someone who combined this with hungarian notation, eliminating all domain meaning from the variable names. The best part was that he was quite proud how much useful information this scheme conveyed...
Admin
"A few months later, the same ____ called to see if I'd be interested in an interview. One thing led to another, and I ended up taking ___________"
Whatever you fill in the blank with is a product of your imagination, not mine.
Admin
Let me postulate on the antipatterns/code smells this may contain:
* When the developer clearly meant to use C.
Admin
This code is self-documenting.
What it documents is the coder's lack of "real world" experience.
Admin
The really, really frightening thing here is that the variable names are just meaningful enough to convey the information that this appears to be an application for controlling a nuclear reactor.
Admin
TRWTF is that he repeats int all the time. What a waste of space!
Admin
Admin
Admin
Now that's organization! I have all my variables in one file, all my constants in an other, and all my functions in a third one. Can't get lost.
Reminds my of that friend who had brought back his first computer to Wal-mart one month after buying it, because it wouldn't start. I told him he could have come to me first, and asked him about the issue he had had. He told me he didn't understand what happened, he was "sorting his files" when it just stopped working.
He had grouped all the files he could find in his hard drive by file extension, in separated folders located in the root of C:. It probably stopped working when he was moving all these .dll files that were everywhere... His way of solving Windows Millenium dll hell, I guess!
Admin
I can actually top this. The previous developer on a legacy application I support used nonsense like this for his global variables, and single letters for his local variables. It was just his "style." Oh, and it's VB6.
Although, given his working conditions I can almost understand. He majorly underestimated the cost of a project and ended up falling several months behind. My company hired more contractors whose only job was sitting there and watching him code. Can't imagine anybody's code would be very beautiful in that situation...
Admin
ints.
Admin
With a name like "barbie", I'm betting your not a developer (I joke).
Admin
Admin
Oh .. oh my. I wonder what university this is? Hopefully one with a very small reactor.
Admin
Admin
Coding is hard! Let's write documentation!
Admin
Admin
Admin
Did you go to college or maybe do a little research??
http://en.wikipedia.org/wiki/List_of_nuclear_reactors#Civilian_Research_and_Test_Reactors_Licensed_To_Operate
Admin
FTFY
Admin
http://en.wikipedia.org/wiki/List_of_nuclear_reactors
Lots of nuclear reactors are in universities.
I`m just waiting for the news of a small nuke somewhere...
Admin
There are quite a few model reactors at various universities. (ex. http://www.murr.missouri.edu/)
Admin
4/10. It would have been 9/10 if you used a less ridiculous handle.
Admin
Admin
sorry for playing dumb... but besides the horrible naming and the lack of commenting, does anything speak against declaring your variables in one place, at the top? what makes that bad style per se?
Admin
ints that represent [x,y] coordinates, they are coordinints.
Admin
Let's hope it's a simulation.
Admin
...do I even want to know why the U.S. Veterans Administration has a nuclear reactor?
Admin
Off the top of my head: encapsulation suffers. A big long method with lots and lots of variables smells bad to start with. But when the variables are declared near where they're used it makes it easier to control their scope. If you then declare those variables inside their control structures, it makes it less possible to make the mistake of overwriting a needed value of a variable with another one.
Admin
Hey, I think I can read my name in there!
Admin
I think I worked out what's wrong.
The first two lines, the comment style is different.
The first line, there's a // at the end of the line, in the second there's not.
That's the real WTF, innit?
Admin
Ok, a method with that many local variables smells so bad it'll probably make you puke. But the rest is really a matter of taste and discipline, I guess. Having to declare all variables in one place (as in Pascal) forces you to think very thoroughly about what kind of data you really need to have locally, and it can thus (if it's done well) lead to much clearer code. It also reduces the risk of unnecessary and redundant declarations and subseqeuntly allocations, esp. in long methods.
Admin
That is so cool. Siax Turbyl Rodiny. New meme! New meme!
Admin
When I was a freshman in high school I wrote a space invaders clone without functions or arrays in qbasic. It had:
MON1X, MON1Y ... MON32X, MON32Y defined.
I became an expert at <backspace> <number> <down> <repeat>. I was pretty proud.
Admin
My compiler of choice would actually warn me about declared but uninitialized variables. Do you not get that with Java?
Admin
I'm wondering what possible business logic would require that you compare the X position of right-hand pump number 1 with the Y position of right-hand pump number 6. Oh I see, if someone's picked it up and moved it east rather further than the northernmost pump is northwards, it means we've got a felon in the compound. Seal the exits.
Admin
I was using common sense: is nuclear technology something I want ungraduated physics students playing around with? In my school, several of the physics classes I took had the correct answers circulated, even on public websites. I alerted the professors each time I discovered this, and they never seemed to mind. Perhaps the purpose was to help the athletic program...at any rate, are those the kids you want working on reactors nestled in a large concentration of people?
Second, do I want Iranian exchange students getting-to-know the inner workings of our nuclear reactors?
Third, have you seen what many of the professors are capable of? I know you've been visiting this site long enough.
Fourth, what's wrong with my pseudonym? I was thinking of registering under this name.
Admin
Admin
You're not allowed to use Java for a nuclear reactor. It's in the license.
Seriously, I'm not making that up.
Admin
I like that alot.
Admin
I thought rodDowny was Robert Downy Jr.'s brother.
Admin
Aaron continues, "good job, you've created all the variables. Now, what the $#@~! are they?!"
XY co-ordinates of various items, which sound like...
Pump Right B 1 to 5 Pump Left B 1 to 5
Valve HB 1 to 4 Valve VB 1 to 4
4 L&R pumps have 4H&V valves, and 1 set (left and right) has no valves? Not sure what the H and V would be. If V was a typo (repeated through copy&pasting), it could be C for hot and cold.
TC 1 to 4 SI A and B VIL 1 to 4
No idea on these. Turbine control? Steam Inlet?
Rod Up, Down, Auto, 10, 5, 1 Perhaps for adjusting control rod(s) by 1/5/10 units at a time, up or down, or automaticaly.
W A&B 1 to 4 and Warn (presumably they're all warnings of some type, 1 set of A and B for each set of H/V valves?).
(Steam) Turbine, Trap (??), Gauge L and S, RodIn (Single control rod? Maybe it only has one), Reactor, Joint (??).
SG 1 to 4. Steam gauges?
So yeah, it sounds like it could be a (small) nuclear reactor. Though given the co-ords, it's more likely just a diagram of it, and the program lets the user rotate it and zoom and or whatever.
I hope this post doesn't come out as garbage. Never tried this before.