Stupid method names and retarded conventions
When it comes to naming conventions, the core JDK has its fair share of ludicrously chosen names. While there isn’t a horrifically large number of these, what is there is bad enough to make up for the lack of quantity in an impressive lack of quality.
One of the offenders is that Thread class. I give you…isInterrupted, and interrupted. Intuitively enough, one version of this method clears the interrupted status, the other does not. Probably more familiar is the ubiquitous System.arraycopy. Would it have killed them to uppercase the C?
Lest you think that these naming heresies are restricted to method names, we have the entirety of java.logging. What next, java.xmling? java.utiling? javax.webbing? There is also the wonderful java.nio. It isn’t non-blocking IO (based on the contents of the package), so the other alternative is the ridiculos ‘new IO’. What happens in 3 years time when the even newer IO shows up? java.enio? How about in 5 years when the novelty has worn off and there’s nothing new about the ‘new IO’?
However, the JDK’s errors aren’t so bad in the grand scheme of things. The crimes committed by other developers are far far worse. Worst of all are the C rejects, with their underscore fetish. MS morons bring in their own style of idiocy, with an insatiable lust for Hungarian Notation. Seeing mStrObj is likely to result in violent spasms for even the most battle hardened amongst us. No less evil is m_thefield, or p_myfield. Use a civilised IDE if you’re so obsessed about distinguishing fields from variables, you dinosaur.
Finally, for all you CORBA tards, I
It never ceases to amaze me how many people seem to just not ‘get’ the java naming conventions. I used to think it’s a matter of common sense and a simple logical process, turns out there’s art involved too. Who knew!
July 31st, 2003 at 2:54 am
Todays rant sounds like a whining baby who needs to be angry at something.
Code in Perl the mother of all write only languages.
July 31st, 2003 at 3:03 am
Hi,
common please elaborate a few of your bile spasms …
> [...] No less evil is m_thefield, or p_myfield. > Use a civilised IDE if you’re so obsessed about > distinguishing fields from variables, you
> dinosaur.
Why is it bad to distinguish instace field from variables?
Using a good IDE is clearly _not_ a solution as that argument buries naming and coding conventions all together. You clearly are very obsessed about method naming - so what about your IDE doesn’t it help you along?!
And don’t start ranting about coding flow or memorisation issues - your IDE clearly should alleviate those problems also - doesn’t it?!
>without the ludicrous prefix to denote interfaces >and we might consider letting you back into >civilised society.
Discussion about coding and naming styles using non zealot(aka JBoss)-like arguments is very much appreciated. Please enlighten us few turds with your wisdom about naming conventions and particularly as to _why_ they’re good or bad. okay you’ve to actually think about the issues but that doesn’t seem too hard for you.
> It never ceases to amaze me how many people seem > to just not ‘get’ the java naming conventions. I > used to think it’s a matter of common sense […
Why do you think the sun java naming conventions the rosetta stone of java coding. Sun has always had a few good and lots of bad ideas. So why revere and do a singsong about their coding conventions document?
July 31st, 2003 at 3:43 am
You neglected to mention System.gc(), Color.black, Color.white() and so on. And while we are at it, what about Hashtable, and InetAddress.
So what are you, or anyone else, going to do about it? Throwing bile and name-calling may be fun and all but it does not change anything.
As for Hungarian or other systems of prefixes, I had a bunch of Indian developers who insisted on putting l_local_var, g_global_var, p_method_param and so on. Shrug. To each his own.
Want to go further? What about the tab vs space wars and shall we discuss how many spaces per tab? What about putting open parantheses on the same line or the next line?
We will always have people arguing about it, and stuff like this will never end.
July 31st, 2003 at 5:21 am
I’m with Hani on this. Java, more so than any other language I’ve worked with, has a coding convention that the majority of developers follow fairly closely. When I encounter code that uses crap like underscores or Hungarian Notation it sticks out like a sore thumb. I can accept that C++ developers think disparate variable names is a way of life, but any experienced Java should know better.
As Hani points out, IDEs are quite capable of conveying the difference between static/instance variables, indicating the object’s class etc. And in ways that are far less disruptive than mentally having to parse garbage like ‘mStrObj’ every few seconds. Besides, consistency in style is good regardless, since it avoids having to make small mental mode-shifts as you work across classes (or even within the same class!) where different conventions are used.
As for whitespace, tabs, bracket layout - virtually irrelevant these days thanks to code layout tools, VCS that can normalise the layout etc. AFAIK there are no tools that can normalize your naming conventions, this responsibility falls squarely onto the developer.
July 31st, 2003 at 5:49 am
While Sun provides countless examples of bad namings throughout the JDK, as do many commonplace third-party libs (including many in Jakarta, for instance), the few cornerstones of Sun’s naming conventions make a lot of sense, in my opinion.
This is *not* to say their whole writing style guide does, for it sure does not.
As for field/method distinction, there are very few cases when fields should be other than private, as many good reviews will tell you (including Joshua Bloch’s _Effective Java_), which means that most of my fields start with an underscore, a long-standing convention for private field names. Therefore, I very seldom come across a field name that does not, which makes for rare questioning on the nature of identifiers.
July 31st, 2003 at 5:50 am
Talking about writing style, isn’t there anything you can do, Hani or Freeroller guys, about this damn amp-coding of single quotes in the comments?! Damn, that sucks!
July 31st, 2003 at 7:32 am
Bah, complaining about method and class naming issues in the JDK is like shooting fish in a barrel (Url, URL is one you missed).
Please try harder Hani.
July 31st, 2003 at 11:06 am
We love the apostrophe…without it FreeRoller would be perfect and we would have nothing to strive for - life would be void of meaning.
July 31st, 2003 at 12:32 pm
Yes, peaople need to be remainded that there is such thing as “Code Conventions for Java Programming Language”. Because many new people come to Java and because Java grown so big that it is easy to miss this aspect.
As far as the underscores and prefixes are concerned, there is _no_ justification for that. What are you, writing methods that exceed one page? C”mon! And please, take care to minimize the distance between the variable declaration and its first use, and be at peace…
July 31st, 2003 at 12:40 pm
After being bitten by this a couple of times I do now prefix fields with m. Granted that Eclipse underlines this as a warning - but not all IDEs would.
private int interruptTime;
public Foo( int interuptTime ) {
this.interruptTime = interruptTime;
}
July 31st, 2003 at 7:06 pm
Not only would the likes of intelliJ and Eclipse warn you about this, using them properly would mean its highly unlikely that you actually typed this piece of code in the first place….
BTW: IntelliJ’s explanation of this warning is amusing : “Silly assignment”
Yep. It is, alright.
-Nick
August 1st, 2003 at 5:57 am
i agree with Hani completely on this one. The pain with the JDK classes is, that they will not fixed as long as java is on the table. Of course its silly to break backwards compatibility because of naming, but there is so much old trash in the JDK, that some general cleaning would be nice.
August 1st, 2003 at 10:54 am
> We love the apostrophe…without it FreeRoller
> would be perfect and we would have nothing to
> strive for - life would be void of meaning.
Even without the apostrophe you could strive for adequate uptimes.
August 1st, 2003 at 12:58 pm
Oh, and the Url versus URL saga in the Servlet API …
August 11th, 2003 at 9:22 am
Why is there one guy on our team who insists that it is no slower coding in vi and using javac, except perhaps for the total absence of debugging and BTW that is why he has written all his code in Hungarian and used Is to signify interfaces.
I know it is an interface - IT IS PURPLE. I know that it is an instance variable, as the tooltip tells me it is, you MORON. And I have a debugger to boot.
Maybe that is why my productivity is more than yours…
August 11th, 2004 at 12:10 pm
noun_subj_Prefixing verb_is aj_silly. noun_subj_Context verb_is quantifier_all noun_you verb_need.