Comment On A Method by Any Other Name

K. K. sent in an example of his company's naming conventions for methods, in which if you have a method that's used frequently, you repeat part of its name for dramatic effect. [expand full text]
« PrevPage 1 | Page 2Next »

Re: A Method by Any Other Name

2008-04-09 08:05 • by NSCoder
The Real WTF is that Jake has already told us the Real WTF so the commenters will have to give the No Dude Seriously Real WTF.

Re: A Method by Any Other Name

2008-04-09 08:09 • by No Dude, Seriously (unregistered)
188837 in reply to 188836
NSCoder:
The Real WTF is that Jake has already told us the Real WTF so the commenters will have to give the No Dude Seriously Real WTF.


I think you'll find that it's actually GetTheRealWTFCaseTheRealWTF.

Re: A Method by Any Other Name

2008-04-09 08:14 • by tragomaskhalos (unregistered)
188838 in reply to 188836

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().
(Perhaps unsurprisingly, the project was doomed).

Re: A Method by Any Other Name

2008-04-09 08:19 • by Vollhorst (unregistered)
The first one looks like a lot of functions which just pass the function name to a sql-server and return the result. Kind of prepared statements. *shudder*

Re: A Method by Any Other Name

2008-04-09 08:22 • by taylonr
188840 in reply to 188838
tragomaskhalos:

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().
(Perhaps unsurprisingly, the project was doomed).


That's stupid. Everyone knows you name functions like that ADoRunRunRunADoRunRun()

Re: A Method by Any Other Name

2008-04-09 08:23 • by Livid Gibbon (unregistered)
188841 in reply to 188838
tragomaskhalos:

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().
(Perhaps unsurprisingly, the project was doomed).

Makes more sense if you sing it:

http://en.wikipedia.org/wiki/Da_Doo_Ron_Ron

Re: A Method by Any Other Name

2008-04-09 08:23 • by Erick
188842 in reply to 188838
tragomaskhalos:

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().


You met it on a Monday and your heart stood still.
The doRunRunRun(), the doRunRun().

Re: A Method by Any Other Name

2008-04-09 08:35 • by ParkinT
188843 in reply to 188842
Erick:
tragomaskhalos:

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().


You met it on a Monday and your heart stood still.
The doRunRunRun(), the doRunRun().

Someone told you it was written by a coder named 'Jill'
The doRunRunRun(), the doRunRun()

Re: A Method by Any Other Name

2008-04-09 08:40 • by galgorah
188844 in reply to 188842
Erick:
tragomaskhalos:

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().


You met it on a Monday and your heart stood still.
The doRunRunRun(), the doRunRun().


The shear stupidity astounds you still.
The doRunRunRun(), the doRunRun().
...

Lets make a full song out of this. Perhaps I'll even write some music for it after.

Re: A Method by Any Other Name

2008-04-09 08:45 • by jpaull
The SQL may not be a total WTF. In my job, I have seen similar things where the RealRegionID might assign it to a geographical region and the RegionID might be used to assign it to a specific Regional Manager. I think these might be instances where a manager is moved from one region to an adjacent one and for whatever reason, they maintain responsibility for some of the sites in their previous region.

Re: A Method by Any Other Name

2008-04-09 08:49 • by ChrisHowe (unregistered)
GoKMartInCincinnatiKmartInCincinnatiGottaGoKMart()

Re: A Method by Any Other Name

2008-04-09 08:50 • by NSCoder
188847 in reply to 188844
galgorah:
Erick:
tragomaskhalos:

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().


You met it on a Monday and your heart stood still.
The doRunRunRun(), the doRunRun().


The shear stupidity astounds you still.
The doRunRunRun(), the doRunRun().


[Edit] ParkinT's addition which mine responds to but wasn't actually quoted in the post I replied to:
Someone told you it was written by a coder named 'Jill'
The doRunRunRun(), the doRunRun().

[and now mine]
You can't really blame her, she had a codebase to fill.
The doRunRunRun(), the doRunRun().

Re: A Method by Any Other Name

2008-04-09 08:50 • by WTFNameWTFNameWTFNameWTFNameWTFName (unregistered)
Did you spot the two spelling mistakes? WFField and WFTracking Entry obviously should read WTFField and WTFTrackingEntry.

Re: A Method by Any Other Name

2008-04-09 08:52 • by Matt (unregistered)
188849 in reply to 188844
galgorah:
Erick:
tragomaskhalos:

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().


You met it on a Monday and your heart stood still.
The doRunRunRun(), the doRunRun().


The shear stupidity astounds you still.
The doRunRunRun(), the doRunRun().
...

Lets make a full song out of this. Perhaps I'll even write some music for it after.


Yes my heart stood still
Yes her name was Jill
And when she redirected me to 127.0.0.1
The doRunRunRun(), the doRunRun().

Re: A Method by Any Other Name

2008-04-09 08:57 • by Will (unregistered)
Those aren't even methods; they're classes.

Re: A Method by Any Other Name

2008-04-09 08:57 • by LieutenantFrost
Song In Progress:

...


And we computer nerds wonder why nobody understands our brand of humor. :D

Re: A Method by Any Other Name

2008-04-09 09:02 • by Livid Gibbon (unregistered)
188852 in reply to 188847
NSCoder:
galgorah:
Erick:
tragomaskhalos:

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().


You met it on a Monday and your heart stood still.
The doRunRunRun(), the doRunRun().


The shear stupidity astounds you still.
The doRunRunRun(), the doRunRun().

You can't really blame her, she had a codebase to fill.
The doRunRunRun(), the doRunRun().

Yeah she was paid by the line,
Yeah so her approach was fine

Re: A Method by Any Other Name

2008-04-09 09:08 • by kaya (unregistered)
188853 in reply to 188838
was the product called Gabriel?

Re: A Method by Any Other Name

2008-04-09 09:10 • by OperatorBastardusInfernalis
YOU'RE
WINNER

Re: A Method by Any Other Name

2008-04-09 09:18 • by Kiss me I'm Polish
TheNewRealWTF is
TheNewRealWTF2 is
TheRevampedWTF is
TheRevampedWTF2 is
TheRealWTF3_0 is
TheRealWTF3_0new is
TheNewRealWTF3_0new is RunRunLolaRunLolaRun

Re: A Method by Any Other Name

2008-04-09 09:26 • by Smash (unregistered)
SendCommentToTDWTFSendToTDWTFCommentToTDWTF

Re: A Method by Any Other Name

2008-04-09 09:39 • by Christopher (unregistered)
Someone explain the "zero" wtf?

Is it because they're using floating point math (therefore causing the result to not be exactly zero)?

Re: A Method by Any Other Name

2008-04-09 09:44 • by Anonymous (unregistered)
188861 in reply to 188860
It is because the three lines could be perfectly abbreviated to
car[0].act.speed = 0;

...would even be faster.

Re: A Method by Any Other Name

2008-04-09 09:53 • by Even Faster Zero Speed (unregistered)
188862 in reply to 188861
Anonymous:
It is because the three lines could be perfectly abbreviated to
car[0].act.speed = 0;
...would even be faster.
But "even faster" and "speed is zero" don't quite mix. That must be why it took them three lines of code to set the speed to zero.

Re: A Method by Any Other Name

2008-04-09 09:54 • by silent d (unregistered)
188863 in reply to 188838
tragomaskhalos:

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().
(Perhaps unsurprisingly, the project was doomed).


if (day_of_week.equals("Monday"))
{
if (suitor_name.equals("Phil")
{
doDoRunRunRun()
doDoRunRun()
}
}

Re: A Method by Any Other Name

2008-04-09 09:59 • by Smash (unregistered)
188864 in reply to 188860
Other than creating a completely unnecessary variable, the guy called
sp -= sp;
which means
sp = sp - sp;

Of course, it always evaluates to 0. Why couldn't he just use car[0].act.speed = 0; is beyond me

Re: A Method by Any Other Name

2008-04-09 10:00 • by MindChild (unregistered)
188865 in reply to 188855
Kiss me I'm Polish:
TheNewRealWTF is
TheNewRealWTF2 is
TheRevampedWTF is
TheRevampedWTF2 is
TheRealWTF3_0 is
TheRealWTF3_0new is
TheNewRealWTF3_0new is RunRunLolaRunLolaRun


I get your joke, and why people are perplexed by the article... but this isn't a case of reimplementing the same function over and over. These do likely correlate with Stored Procedures or something akin to such, but this is just a bad case of not knowing how to use function overloading. I've done this very thing before (don't hate), but on the database side. The idea was depending on what information you had, you had a different stored procedure to get your result, because, well, your database server doesn't have stored procedure overloading...

"GetCases" for instance is likely to return multitudes of records. But if you have a WorkflowID to filter some of it down, you would use "GetCasesWorkflow". Got a UserID too? "GetCasesWorkflowUser". Don't want to see any Cases older than 5 years old? "GetCasesWorkflowUserFilterBy"... etc etc etc

Re: A Method by Any Other Name

2008-04-09 10:05 • by Just another bloke (unregistered)
188866 in reply to 188865
Yes, and since function overloading is not to be invented for the next fifty years....

Oh, wait...

Re: A Method by Any Other Name

2008-04-09 10:16 • by Anon Fred (unregistered)

It wouldn't surprise me to learn that there is some floating point implementation in which x - x = 0 isn't a guarantee.

I would bet against it being true, but I wouldn't be surprised to be wrong about it.

Re: A Method by Any Other Name

2008-04-09 10:19 • by fred (unregistered)
188876 in reply to 188875

It wouldn't surprise me to learn that there is some floating point implementation in which x - x = 0 isn't a guarantee.

I would bet against it being true, but I wouldn't be surprised to be wrong about it.


So you will have lost you bet in all IEEE floating point implementations.

If x is NaN, x-x is also NaN.

Cheers

Re: A Method by Any Other Name

2008-04-09 10:25 • by Pidgeot
188878 in reply to 188850
Will:
Those aren't even methods; they're classes.


I'm kinda surprised people seem to miss this post - more so because it's true (look at the icons).

Re: A Method by Any Other Name

2008-04-09 10:28 • by Jack CMU (unregistered)
188879 in reply to 188850
Will:
Those aren't even methods; they're classes.


That's absolutely right. This is from .NET, where a method is represented by a little pink isometric cube.

I'm doing research on API usability right now (this site is a gold mine!) and this looks very similar to common SOAP web service API patterns.

To keep their web methods extensible many web service companies only send in one parameter with the method, and then that parameter is an class with "child" classes, which also have children, etc. Then you can add any new "parameters" without breaking old code, or overloading parameters in a weird chronological order that doesn't make sense. So to tell people how to assemble the data structure that the SOAP XML message sends in, web service API designers sometimes encode the assembly information into the name, like so:

Customer cust = new Customer();
Customer.Selection = new CustomerSelection();
Customer.Selection.Name = new CustomerSelectionName();
Customer.Selection.Name.FirstName = "Bob";

Then they ship out "cust" as a parameter. If you wanted to change the service to add functionality to support a SecondName or ThirdName, all old code would still work. Also, the autocomplete would fill with:

Customer
CustomerSelection
CustomerSelectionName
etc.

So here TRWTF is either (1) this actually ISN'T a web service namespace and the resemblance is bizarre, or (2) current web service stub generators are so primitive the only way to get parameters assembled correctly is to hand developers these wacky lego-block naming schemes.

Extra credit if you know what a "Whiz-Dull" is. :)

Re: A Method by Any Other Name

2008-04-09 10:30 • by Aaron
188880 in reply to 188865
MindChild:
"GetCases" for instance is likely to return multitudes of records. But if you have a WorkflowID to filter some of it down, you would use "GetCasesWorkflow". Got a UserID too? "GetCasesWorkflowUser". Don't want to see any Cases older than 5 years old? "GetCasesWorkflowUserFilterBy"... etc etc etc

Or you could do the entire thing with one GetCases procedure.

CREATE PROCEDURE dbo.GetCases

@WorkflowID Int,
@UserID Int,
@BeginDate DateTime
AS

SELECT *
FROM Cases
WHERE (@WorkFlowID IS NULL OR WorkFlowID = @WorkFlowID)
AND (@UserID IS NULL OR UserID = @UserID)
AND (@BeginDate IS NULL OR CreationDate >= @BeginDate)


Voila. And since most modern languages support nullable primitives, you only need one code-level method to support this. No overloading necessary.

Overloading generally isn't the best solution to, well, anything. But as the saying goes, when all you have is a hammer...

Re: A Method by Any Other Name

2008-04-09 10:37 • by Pete Repete (unregistered)
As a person that suffers from multiple repeat syndrome (MRS) I find this article insensitive and offensive.

As a person that suffers from multiple repeat syndrome (MRS) I find this article insensitive and offensive.

Sincerely Pete Repete

Sincerely Pete Repete

Re: A Method by Any Other Name

2008-04-09 10:43 • by anonymous (unregistered)
188883 in reply to 188882
Do you know my friend "Pete Repeat"?

He wrote just like you, except he had better spelling.

Re: A Method by Any Other Name

2008-04-09 10:43 • by bubba (unregistered)
"Wizz-dull" or WSDL would be Web Service Definition Language.

Re: A Method by Any Other Name

2008-04-09 10:45 • by TakeASeatOverThere
188885 in reply to 188838
tragomaskhalos:

I once worked on a codebase where a function run() called another function doRun() which called another function doDoRunRunRun().
(Perhaps unsurprisingly, the project was doomed).

Obviously it was supposed to be a robotic running dodo. Too bad the AIBO came out first.

Re: A Method by Any Other Name

2008-04-09 10:47 • by jo42
188886 in reply to 188864
Smash:
Other than creating a completely unnecessary variable, the guy called
sp -= sp;
which means
sp = sp - sp;

Of course, it always evaluates to 0. Why couldn't he just use car[0].act.speed = 0; is beyond me

In The Olden (Golden) Days, before all this OOP clap trap was pOOPed upon us from ivory towers, if sp was a float and sufficiently small or large, that operation would not return 0.0

Re: A Method by Any Other Name

2008-04-09 10:47 • by Pope
188887 in reply to 188865
MindChild:

These do likely correlate with Stored Procedures or something akin to such [...]
But if you have a WorkflowID to filter some of it down, you would use "GetCasesWorkflow". Got a UserID too? "GetCasesWorkflowUser". Don't want to see any Cases older than 5 years old? "GetCasesWorkflowUserFilterBy"... etc etc etc


I use a similar naming method for stored procedures: ObjectVerbByQualifiers, or IdeaVerbByQualifiers. Such as: SurveyUpdate, or AnswerGetByQuestionId. They can kind of get long winded though when you have intermediate tables linked to several tables.

But the reason I brought it up was because I think I remember a WTF where someone mentioned that method as a WTF. Can't find it, though... so I can't remember why it was a WTF. Maybe it was just a really long name.

Re: A Method by Any Other Name

2008-04-09 10:52 • by MindChild (unregistered)
188889 in reply to 188880
Aaron:
MindChild:
"GetCases" for instance is likely to return multitudes of records. But if you have a WorkflowID to filter some of it down, you would use "GetCasesWorkflow". Got a UserID too? "GetCasesWorkflowUser". Don't want to see any Cases older than 5 years old? "GetCasesWorkflowUserFilterBy"... etc etc etc

Or you could do the entire thing with one GetCases procedure.

CREATE PROCEDURE dbo.GetCases

@WorkflowID Int,
@UserID Int,
@BeginDate DateTime
AS

SELECT *
FROM Cases
WHERE (@WorkFlowID IS NULL OR WorkFlowID = @WorkFlowID)
AND (@UserID IS NULL OR UserID = @UserID)
AND (@BeginDate IS NULL OR CreationDate >= @BeginDate)


Voila. And since most modern languages support nullable primitives, you only need one code-level method to support this. No overloading necessary.

Overloading generally isn't the best solution to, well, anything. But as the saying goes, when all you have is a hammer...


Bullox. You completely assume this is all coming out of one table. What if, for each extra param, you had a join onto another table... not so big, you can just use an IF of some sort... but then you are taking a purely single-query-and-nothing-else Stored Procedure, which tends to get optimized, or "planned" well ahead of time, to evaluated code, which I know of several RDBMS's *cough*Interbase*cough* that then refuse to construct a plan, because the result or the path to the result isn't determinable ahead of time.

Re: A Method by Any Other Name

2008-04-09 11:03 • by Derek Hartley (unregistered)
To be honest, I'm not sure that the HTML is actually a WTF. I presume the idea is that it's a level 2 header but the class is h3? Surely this could simply be a case of having multiple header styles and the coder just wishing to use the 3rd one?

Re: A Method by Any Other Name

2008-04-09 11:37 • by Some Mathematician (unregistered)
188899 in reply to 188838
TFA:
And from a database schema:

CREATE TABLE Properties
(
/* SNIP */
RegionID INT NOT NULL REFERENCES Regions(RegionID),
RealRegionID INT NOT NULL REFERENCES Regions(RegionID),
/* SNIP */
)

The real WTF is that he forgot a NoDudeSeriouslyRealRegionID column.


Actually, he just left out the next column. Once you see it, you'll agree the schema makes sense:

CREATE TABLE Properties
(
/* SNIP */
RegionID INT NOT NULL REFERENCES Regions(RegionID),
RealRegionID INT NOT NULL REFERENCES Regions(RegionID),
ComplexRegionID INT NOT NULL REFERENCES Regions(RegionID),
/* SNIP */
)

Yes, I am customer 462846 - 6i.

Re: A Method by Any Other Name

2008-04-09 11:38 • by Skaven
188901 in reply to 188891
I was thinking the same thing? What's wrong with using a different class for the High Explosives AD #3?

Re: A Method by Any Other Name

2008-04-09 11:48 • by Justin (unregistered)
The real WTF is Stored Procedures for dynamic selects in the comments.

Re: A Method by Any Other Name

2008-04-09 12:14 • by JUST ANOTHER WTF (unregistered)
188906 in reply to 188864
Smash:
Other than creating a completely unnecessary variable, the guy called
sp -= sp;
which means
sp = sp - sp;

Of course, it always evaluates to 0. Why couldn't he just use car[0].act.speed = 0; is beyond me


Obviously so he can get that little bit of floating point error at the end... he doesn't want 0 he wants 1.432322323E-14!

Re: A Method by Any Other Name

2008-04-09 12:18 • by Twon
The real WTF is that he forgot a NoDudeSeriouslyRealRegionID column.


This is different from mysql_*_escape_string... how? There's precedent! Bad precedent, but precedent.

Re: A Method by Any Other Name

2008-04-09 12:26 • by Anonymous (unregistered)
188908 in reply to 188864
Smash:
Other than creating a completely unnecessary variable, the guy called
sp -= sp;
which means
sp = sp - sp;

Of course, it always evaluates to 0. Why couldn't he just use car[0].act.speed = 0; is beyond me


when sp is NaN or Infinity, sp - sp evaluates to NaN.

Re: A Method by Any Other Name

2008-04-09 12:36 • by dextron
188911 in reply to 188908
when sp is NaN or Infinity, sp - sp evaluates to NaN.


So,

If car[0].act.speed="smokin" <-- see, not a number!

is evaluated earlier in the program.

car[0].act.speed=0

would be incorrect.

Re: A Method by Any Other Name

2008-04-09 12:43 • by Zecc
188913 in reply to 188899
Some Mathematician:

Actually, he just left out the next column. Once you see it, you'll agree the schema makes sense:

CREATE TABLE Properties
(
/* SNIP */
RegionID INT NOT NULL REFERENCES Regions(RegionID),
RealRegionID INT NOT NULL REFERENCES Regions(RegionID),
ComplexRegionID INT NOT NULL REFERENCES Regions(RegionID),
/* SNIP */
)

Yes, I am customer 462846 - 6i.

You deserve to be quoted at least once.

Re: A Method by Any Other Name

2008-04-09 12:57 • by FredSaw
188915 in reply to 188884
bubba:
"Wizz-dull" or WSDL would be Web Service Definition Language.
Nonsense. It means nothing unusual happened while you were in the restroom.
« PrevPage 1 | Page 2Next »

Add Comment