Comment On In A Rush, Properly Handled, and More

"This code was left by the Senior Software Consultant," Michael Wheeler writes, "I'm not sure if it's insurance against 'Return' not returning... or a comment that explained why the line of code was left in." [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Robots in disgust

2010-03-10 09:06 • by Bosshog (unregistered)
Transformer optimusPrime = new Transformer()

WIN!

Re: In A Rush, Properly Handled, and More

2010-03-10 09:07 • by WhiskeyJack
Whoever wrote that article seems to be the one that's "in a rush", judging by all the copy/paste errors.

--
Note from Alex: Whoa. I swear, at like 3AM last nite it looked perfect! (Fixed)

Re: In A Rush, Properly Handled, and More

2010-03-10 09:09 • by @Deprecated (unregistered)
WhiskeyJack:
Whoever wrote that article seems to be the one that's "in a rush", judging by all the copy/paste errors.


Hey give Alex a break, he's all wiped after having to implement some impossible features that were sold to a customer.

As for the:
public long getLength() {
return 1000000; // no clue
}

I am afraid I have done something similar from time to time, when I am going through some inherited code where the original dev is long gone, and putting in something like
// OMGWTF I can't believe this #$$@#

Why do I put that in there? Venting or something, I guess...

Re: In A Rush, Properly Handled, and More

2010-03-10 09:14 • by SR (unregistered)
The comments for validation one is something I'd do while still learning to program effectively. Of course I'd go back and replace them with code before putting it into production.

As for optimusPrime = new Transformer() - that is teh awesome! :oD

Re: In A Rush, Properly Handled, and More

2010-03-10 09:16 • by Richard T. Roll (unregistered)
All of this is fine on embedded platforms which might not have a file system.

Re: In A Rush, Properly Handled, and More

2010-03-10 09:17 • by AndyC (unregistered)
It's a bit unfair to just clip bits of code out of context. If you'd left in the public class PieceOfString bit the getLength method makes perfect sense!

Re: In A Rush, Properly Handled, and More

2010-03-10 09:17 • by Another PHP Guy (unregistered)
function DeUnicode($_input){

//added to strip out italics tag <i> from name
$_input = str_replace('<i>', '', $_input);
$_input = str_replace('</i>', '', $_input);
return $_input;
}


Sure the PHP guy wasn't in a rush. He had simply could use strip_tags instead of his own function.

facilisi -- facilis is latin for easy to do

Re: In A Rush, Properly Handled, and More

2010-03-10 09:19 • by me_again (unregistered)
Transformer optimusPrime = new Transformer();

is this a wtf because it's cool?

captcha: vulputate - A vulture that likes tater tots.

Re: In A Rush, Properly Handled, and More

2010-03-10 09:28 • by TheSpiesMustFlow (unregistered)
301732 in reply to 301730
me_again:
Transformer optimusPrime = new Transformer();

is this a wtf because it's cool?


Half because it's cool, half because jokes shouldn't go in production systems I guess.

Re: In A Rush, Properly Handled, and More

2010-03-10 09:29 • by RayMarron
I find all this anti-Italic sentiment disturbing.

Re: In A Rush, Properly Handled, and More

2010-03-10 09:32 • by True that (unregistered)
301734 in reply to 301730
Transformer optimusPrime = new Transformer();
is only cool if you're working in a graphical environment and instantiating models for rendering where you can pass the constructor arguments, like 'TRUCK', or 'ROBOT', or 'GORILLA' (for the optimusPrimal version).

Re: In A Rush, Properly Handled, and More

2010-03-10 09:32 • by Erasmus Darwin
301735 in reply to 301723
SR:
The comments for validation one is something I'd do while still learning to program effectively. Of course I'd go back and replace them with code before putting it into production.


In that case, it helps to have something greppable (such as FIXME) in the placeholder comments to make sure it doesn't get forgotten before deploying the code.

Re: In A Rush, Properly Handled, and More

2010-03-10 09:36 • by Lorne Kates
class Transformer

class Transformers : Transformer, Collection

Transformer optimusPrime = new Transformer();

Transformers autobots = new Transformers();

optimusPrime->Address(autobots);

optimusPrime->IssueCommand("Transform!!!!");

AwesomeSoundEffectsFactory::GetSoundEffect("ch ch ch CH!")->Play();

Re: In A Rush, Properly Handled, and More

2010-03-10 09:39 • by Anonymous (unregistered)
I'm pretty sure that the first function posted (the more I read into it) is a waste of space.

Re: In A Rush, Properly Handled, and More

2010-03-10 09:42 • by jrk (unregistered)
I tried to put some italic tags around a bit of text today, but somehow, it doubled my text

I tried to put some italic tags around a bit of text today, but somehow, it doubled my text

Re: In A Rush, Properly Handled, and More

2010-03-10 09:48 • by frits
//Fixed for naming and precision

Public Function kgf()
kgf = 9.80665
End Function

Re: In A Rush, Properly Handled, and More

2010-03-10 09:52 • by java.lang.Chris;

public interface Transformer { ... }

public interface Car extends Transformer { ... }

List<Transformer> transformers = new ArrayList<Transformer>();
transformers.add(new Transformer());

List<Car> robotsInDisguise = (List<Car>) transformers;

Re: In A Rush, Properly Handled, and More

2010-03-10 09:55 • by Anon (unregistered)
301742 in reply to 301725
AndyC:
It's a bit unfair to just clip bits of code out of context. If you'd left in the public class PieceOfString bit the getLength method makes perfect sense!


Indeed, and the Optimus Prime bit might have been from code for a Transformers game, in which case it's perfectly cromulent.

Re: In A Rush, Properly Handled, and More

2010-03-10 09:56 • by SR (unregistered)
301743 in reply to 301735
Erasmus Darwin:
In that case, it helps to have something greppable (such as FIXME) in the placeholder comments to make sure it doesn't get forgotten before deploying the code.


That's exactly what I did. "FIXME" and "TODO write this code" are good, though I've still a soft spot for "banana"

Re: In A Rush, Properly Handled, and More

2010-03-10 09:59 • by highphilosopher (unregistered)
Wow, you poke at Alex just a little bit, and your comments get deleted? That's really, well, sad. I do understand that everyone makes mistakes, but on a Blog that's dedicated to pointing out mistakes, that's just kind of well hypocritical. Everyone here has made a WTF including you Alex.

--
Note from Alex: there were several comments pointing out typos/mistakes, but since the errors were fixed, the comments were no longer relavent; I did keep one, which was at the top and was a good balance of poking fun at me and explaining the original problem. On the same note, comments that respond to this will probably be deleted, too, since it's double-meta (I think?) discussion.

Re: Robots in disgust

2010-03-10 10:02 • by Dave (unregistered)
301745 in reply to 301716
Bosshog:
Transformer optimusPrime = new Transformer()
WIN!


Too right. I have been guilty of similar naming conventions, like having a boolean flag to indicate if the current user is local or remote (in circumstances where "local" security has been requested to be lower for convenience on the assumption that other protections will mitigate the extra risk) called b_from_round_these_parts. Then you can check
if not b_from_round_these_parts
(needs to be read in either a west country accent or with a hick slur)

Re: In A Rush, Properly Handled, and More

2010-03-10 10:03 • by AndersI (unregistered)
"A nice example of ahead planning," Robert writes, "just in case the Earth's mass dramatically changes overnight, we are prepared for a fast, system-wide adjustment."

Public Function Newton()
Newton = 9.81
End Function


Actually, this should be a function of latitude - see http://en.wikipedia.org/wiki/Gravitational_acceleration.

For us here in Sweden, 9.82 is the best approximation.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:03 • by MP (unregistered)
301747 in reply to 301742
Anon:
AndyC:
It's a bit unfair to just clip bits of code out of context. If you'd left in the public class PieceOfString bit the getLength method makes perfect sense!


Indeed, and the Optimus Prime bit might have been from code for a Transformers game, in which case it's perfectly cromulent.


That would make it even more of a WTF since the article states:

"I was going through some obscure code from the developers before me, and something caught my eye," Philippe wrote. "It was a class whose task was to transform data, and this is how it was instantiated."

Re: In A Rush, Properly Handled, and More

2010-03-10 10:04 • by frits
301748 in reply to 301739
'Fixed for naming and precision

Public Function kgf()
kgf = 9.80665
End Function



'Added to fix the code the jerkoff Senior
'Software Consultant broke.

Public Function Newton()
Newton= kgf
End Function

Re: In A Rush, Properly Handled, and More

2010-03-10 10:07 • by toshir0
301750 in reply to 301724
Richard T. Roll:
All of this is fine on embedded platforms which might not have a file system.

'it's not good

Re: In A Rush, Properly Handled, and More

2010-03-10 10:08 • by toshir0
301751 in reply to 301750
toshir0:
Richard T. Roll:
All of this is fine on embedded platforms which might not have a file system.

'it's not good

'it's good

Re: In A Rush, Properly Handled, and More

2010-03-10 10:10 • by Matt Westwood (unregistered)
301752 in reply to 301748
frits:
'Fixed for naming and precision

Public Function kgf()
kgf = 9.80665
End Function



'Added to fix the code the jerkoff Senior
'Software Consultant broke.

Public Function Newton()
Newton= kgf
End Function



Amateur.

Public Function Newton()
Newton= kgf()
End Function

Re: In A Rush, Properly Handled, and More

2010-03-10 10:12 • by Adrian (unregistered)
Public Function Newton()

Newton = 9.81
End Function


As a mech engineer, I would say it is not too bad, it makes sure you always use the same value and a known accuracy for g trougout the program.

Some people use 9,81, others just 9,8 and some others round it to 10, and the actual value depends on a lot of things ( where you are on the globe, position of the moon....)

This allows get some accuracy of the result and eventualy improve it.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:13 • by TheJasper
RE the italics that become bold I would say that using italic tags is the real wtf. Though it feels strange to redefine this in css, html wasn't meant for defining presentation. That's why you have <Strong> and <Em>. It is unfortunate tags like <i> or <b> exist at all.

Since you can redefine everything in css it is a mistake to think those tags will do what you think.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:13 • by TheJasper
RE the italics that become bold I would say that using italic tags is the real wtf. Though it feels strange to redefine this in css, html wasn't meant for defining presentation. That's why you have <Strong> and <Em>. It is unfortunate tags like <i> or <b> exist at all.

Since you can redefine everything in css it is a mistake to think those tags will do what you think.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:15 • by Anonymous (unregistered)
301758 in reply to 301748
frits:
'Fixed for naming and precision

Public Function kgf()
kgf = 9.80665
End Function

'Added to fix the code the jerkoff Senior
'Software Consultant broke.

Public Function Newton()
Newton= kgf
End Function


ROFL, senior software consultant! We've been reading your crappy angst-ridden comments long enough to know you're still in high-school, frits! Now get the hell back to class!

Re: In A Rush, Properly Handled, and More

2010-03-10 10:17 • by grizz (unregistered)
The Newton function probably is to avoid having a magic number in a calculation. Seems to me that's generally considered A Good Thing, not a WTF.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:21 • by frits
301760 in reply to 301752
Matt Westwood:
frits:
'Fixed for naming and precision

Public Function kgf()
kgf = 9.80665
End Function



'Added to fix the code the jerkoff Senior
'Software Consultant broke.

Public Function Newton()
Newton= kgf
End Function



Amateur.

Public Function Newton()
Newton= kgf()
End Function


Hey man, this is VB. Parentheses optional.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:22 • by DaveK
301761 in reply to 301726
Another PHP Guy:
function DeUnicode($_input){

//added to strip out italics tag <i> from name
$_input = str_replace('<i>', '', $_input);
$_input = str_replace('</i>', '', $_input);
return $_input;
}


Sure the PHP guy wasn't in a rush. He had simply could use strip_tags instead of his own function.
I don't know about you, but <i<i>>I</</i>i> for one can see another problem with it.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:23 • by Leo (unregistered)
301762 in reply to 301759
grizz:
The Newton function probably is to avoid having a magic number in a calculation. Seems to me that's generally considered A Good Thing, not a WTF.


You're the one that does

#define ONE 1
#define TWO 2

aren't you?

Sometimes you really don't need it.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:23 • by Matt Westwood (unregistered)
301763 in reply to 301759
grizz:
The Newton function probably is to avoid having a magic number in a calculation. Seems to me that's generally considered A Good Thing, not a WTF.


Agreed - the only problem I might possibly have with it is its name - NewtonsPerKg would be better - but as a concept it's fine. No WTF.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:25 • by Zachary (unregistered)
"I tried to put some italic tags around a bit of text today," writes Derek, "but somehow, it emboldened my text. I did some digging, and I found that our front-end developer has this in our CSS stylesheet."

i { color: #000; font-weight: bold; font-style: normal; }


The real WTF here is that he is using the i tag to begin with. Any real web developer/designer uses pure CSS.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:25 • by DaveK
301765 in reply to 301744
highphilosopher:
Wow, you poke at Alex just a little bit, and your comments get deleted? That's really, well, sad. I do understand that everyone makes mistakes, but on a Blog that's dedicated to pointing out mistakes, that's just kind of well hypocritical. Everyone here has made a WTF including you Alex.

--
Note from Alex: there were several comments pointing out typos/mistakes, but since the errors were fixed, the comments were no longer relavent; I did keep one, which was at the top and was a good balance of poking fun at me and explaining the original problem

*relevant*

Re: In A Rush, Properly Handled, and More

2010-03-10 10:25 • by Nitpickers R. Lame (unregistered)
Anonymous:

I must admit I tend to agree; delete trolls and totally off-topic posts but don't delete relevant stuff. And if the original article is that messed up then it is perfectly relevant to point it out. Most people were being light-hearted about it, why purge perfectly innocent comments? Can the WTF community not enjoy a meta-WTF once in a while?

highphilosopher:
Wow, you poke at Alex just a little bit, and your comments get deleted? That's really, well, sad. I do understand that everyone makes mistakes, but on a Blog that's dedicated to pointing out mistakes, that's just kind of well hypocritical. Everyone here has made a WTF including you Alex.

md5sum:
It's not the first time I've seen Alex nix a comment that didn't agree with him (including one or two of mine). Lame, but hey, he's the "god" of the wtf, right? Like "WTF did you delete my perfectly valid comment for?". Although, deleting peoples' comments is gonna bite him. Nobody comes here to read the articles, the articles mostly make no sense as a WTF, often containing valid code that the submitter and the writer are unable to comprehend. The COMMENTS though are almost ALWAYS an entertaining read.


In this case none of yours are. Get over yourselves.

Now as to whether this comment about useless comments being useless is useful... Well that's a different question entirely....

Re: In A Rush, Properly Handled, and More

2010-03-10 10:28 • by DaveK
301768 in reply to 301762
Leo:
grizz:
The Newton function probably is to avoid having a magic number in a calculation. Seems to me that's generally considered A Good Thing, not a WTF.


You're the one that does

#define ONE 1
#define TWO 2

aren't you?

Sometimes you really don't need it.
And sometimes you do, because some scientific software has to give actually *correct* results, at any latitude, and even up a mountain, down a mineshaft, or in an orbiting spacecraft. It depends how much precision is required, which is something none of us can infer from a contextless snippet, but if it's even doing physics-based calculations at all, it's certainly possible they might want two or three significant digits of precision, which is the level at which it becomes worth considering variations in g.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:29 • by frits
301769 in reply to 301758
Anonymous:

ROFL, senior software consultant! We've been reading your crappy angst-ridden comments long enough to know you're still in high-school, frits! Now get the hell back to class!


We? Is there a frog in your pocket? For the dense, "senior software consultant" is a callback to the article.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:33 • by SR (unregistered)
301771 in reply to 301756
TheJasper:
RE the italics that become bold I would say that using italic tags is the real wtf. Though it feels strange to redefine this in css, html wasn't meant for defining presentation. That's why you have <Strong> and <Em>. It is unfortunate tags like <i> or <b> exist at all.

Since you can redefine everything in css it is a mistake to think those tags will do what you think.


I agree that it's preferable to use EM and STRONG in place of I and B but redefining expected behaviour is definitely a WTF in my book.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:35 • by Simon (unregistered)
I tried to put some italic tags around a bit of text today," writes Derek, "but somehow, it emboldened my text."


This was a deliberate feature to tell you to stop using <i> to italicise text. The correct XHTML-compliant tag is <em>.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:35 • by DaveK
301773 in reply to 301738
jrk:
I tried to put some italic tags around a bit of text today, but somehow, it doubled my text

I tried to put some italic tags around a bit of text today, but somehow, it doubled my text

Perhaps you could explain how that works?

Re: In A Rush, Properly Handled, and More

2010-03-10 10:39 • by DaveK
301774 in reply to 301772
Simon:
I tried to put some italic tags around a bit of text today," writes Derek, "but somehow, it emboldened my text."


This was a deliberate feature to tell you to stop using <i> to italicise text.
Don't you mean "... tell you to stop using unicode to italicise text ..."?

Re: In A Rush, Properly Handled, and More

2010-03-10 10:40 • by SR (unregistered)
301775 in reply to 301773
DaveK:
jrk:
I tried to put some italic tags around a bit of text today, but somehow, it doubled my text

I tried to put some italic tags around a bit of text today, but somehow, it doubled my text

Perhaps you could explain how that works?


That was referring to a copy and paste error that Alex has now fixed. Kudos on O'Rly, thuogh. It's ages since I've seen one.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:43 • by Helix
301776 in reply to 301765
DaveK:
highphilosopher:
Wow, you poke at Alex just a little bit, and your comments get deleted? That's really, well, sad. I do understand that everyone makes mistakes, but on a Blog that's dedicated to pointing out mistakes, that's just kind of well hypocritical. Everyone here has made a WTF including you Alex.

--
Note from Alex: there were several comments pointing out typos/mistakes, but since the errors were fixed, the comments were no longer relavent; I did keep one, which was at the top and was a good balance of poking fun at me and explaining the original problem

*relevant*


Strangly by discussing about the spelling of relevant you have created a triple-meta comment.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:45 • by ath (unregistered)
301777 in reply to 301759
grizz:
The Newton function probably is to avoid having a magic number in a calculation. Seems to me that's generally considered A Good Thing, not a WTF.


Agree. If you hardcode the values you may screw up badly.
For example, Alice calculates the force as F = 9.81 * m. Later Bob wants to do the inverse so he calculates m = F / 9.8128. Then the swedish guy comes along and calculates F again as F = 9.82 * m. You'd better wish they're programming a game and not the guidance system for an Ariane V rocket.

Sure, I'd prefer a constant to a function but it's still better than hardcoded values...

Re: In A Rush, Properly Handled, and More

2010-03-10 10:47 • by Quirkafleeg (unregistered)
301779 in reply to 301764
Zachary:
Any real web developer/designer uses pure CSS.
That's pointless. You need something else to which to apply the CSS.

Re: In A Rush, Properly Handled, and More

2010-03-10 10:57 • by Quirkafleeg (unregistered)
301780 in reply to 301776
Helix:
Strangly by discussing about the spelling of relevant you have created a triple-meta comment.
‘Strangely’. But then you knew that…
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment