TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonPainter

323 pointsby heydenberkover 12 years ago

32 comments

nostromoover 12 years ago
Someone on StackOverflow suggested we think of ugly Java class names as poetry; he provided an example:<p><pre><code> InternalFrame InternalFrame Title Pane, Internal Frame Title Pane. Maximize Button Window, Not Focused State. </code></pre> <a href="http://stackoverflow.com/questions/1697215/what-is-your-favourite-java-api-annoyance" rel="nofollow">http://stackoverflow.com/questions/1697215/what-is-your-favo...</a>
评论 #4771312 未加载
评论 #4770943 未加载
评论 #4771309 未加载
评论 #4771240 未加载
评论 #4772177 未加载
评论 #4771004 未加载
评论 #4771257 未加载
评论 #4771912 未加载
评论 #4771582 未加载
评论 #4771250 未加载
评论 #4771057 未加载
jacquesmover 12 years ago
I just did a quick analysis of a system with a large number of globally exposed names written in C.<p>About 1000 functions in all (so that's <i>just</i> the globals), of those a hundred have names &#62; 30 characters. There are some real 'gems' in there, consistency - even if self enforced - has a price. The record holder weighs in at 53 characters, it (fortunately) drops off quickly after that.<p>There are only 2 things hard in programming, cache invalidation, naming things and off by one errors.<p>Personally I think this name is bad because in spite of the enormous length it <i>still</i> doesn't tell me what it actually does. It just uses a lot of characters to indicate its spot in a hierarchy.<p>Names like these are what gave rise to jokes like 'Q: What is the spelling of bureaucracy? A: J-a-v-a'. Which of course does a dis-service to java the language and the community behind it.<p>I can see why they're funny, but you have to realize that when you get out of the trivial program length domain into projects that are 100's of thousands of lines that this problem will sooner or later rear its ugly head. And I have not yet seen any really good solutions.<p>The things that can help you to extend your runway a bit in this respect are:<p><pre><code> - be consistent - reduce scope wherever possible - pick short names for primary objects </code></pre> But even with those rules you'll have a 53 letter name in there somewhere... I'd be very wary of casting stones in situations like these without knowing exactly how the person that picked it originally made their choice. Chances are there were a whole pile of external factors dictating this monstrosity and the guy or girl (or the code generator!) that did it never was happy about it either. Laughing at others that have tackled some problem is easy. Coming up with real solutions and doing a better job of it is a lot harder.
评论 #4771050 未加载
评论 #4771794 未加载
评论 #4771328 未加载
评论 #4771265 未加载
espinchiover 12 years ago
Also, in the package com.sun.java.swing.plaf.nimbus, there lies the infamous class InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState (<a href="http://codenav.org/code.html?project=/jdk/1.6.0_22&#38;path=/Source%20Packages/com.sun.java.swing.plaf.nimbus/InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState.java" rel="nofollow">http://codenav.org/code.html?project=/jdk/1.6.0_22&#38;path=...</a>). Quite a precise name for a class that has only 36 lines.<p>Talking about design patterns, the folks that develop the Spring framework apparently tried to put as many of them together as they could: there is a class named AbstractSingletonProxyFactoryBean (<a href="http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.html" rel="nofollow">http://static.springsource.org/spring/docs/2.5.x/api/org/spr...</a>) in the aop package. And, the class description is no less than "Convenient proxy factory bean superclass for proxy factory beans that create only singletons".<p>Take that, GoF.
评论 #4771027 未加载
评论 #4772033 未加载
SCdFover 12 years ago
You can find quite a few of these, and every time I see them linked I shake my head in confusion.<p>I don't understand what I'm supposed to take away from this. That there exists in the world badly named Java classes? And? Is the implication here that because you found an example of a clumsily named Java class the entire language is an usuable write-off? Or that it's somehow indicative of all Java applications?<p>I know Java isn't cool, but I don't see what is achieved by staring, pointing and giggling because you found an example of its use that is ungainly.
评论 #4771092 未加载
beambotover 12 years ago
Almost as good as Microsoft Office's tristate enum with 5 states (three of them not supported), where 0 is False and -1 is True:<p><a href="http://msdn.microsoft.com/en-us/library/aa432714(office.12).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa432714(office.12)....</a>
评论 #4771341 未加载
评论 #4771570 未加载
评论 #4771279 未加载
评论 #4771826 未加载
markokocicover 12 years ago
Seems like automatically generated class name. You shouldn't ever see that as a Java developer unless you work for Sun, since this is internal package. The name, though long, seems pretty consistent with the rest of the names in the package [1].<p>If you look at it once more I guess that it is used as a Painter for MaximizeButton located in InternalFrameTitlePane of InternalFrameTitlePane of InternalFrame.<p>How would you name such thing?<p>[1] <a href="http://javadoc.bugaco.com/com/sun/java/swing/plaf/nimbus/package-tree.html" rel="nofollow">http://javadoc.bugaco.com/com/sun/java/swing/plaf/nimbus/pac...</a>
评论 #4771409 未加载
评论 #4771821 未加载
评论 #4772860 未加载
imglorpover 12 years ago
As good or bad as the Java language may be, I think plenty of people are turned off by the Java culture that encourages this to happen. This is a little bit of an understatement since Sun setting the defacto coding standard gives a very strong message to followers.<p>The rest of the world might simply say blah.bah.frame.paint and be done with it.
评论 #4770953 未加载
evmarover 12 years ago
Here's a query for [\w{60,} lang:java] on Google Code Search:<p><a href="http://code.google.com/codesearch#search/&#38;q=%5Cw%7B60,%7D%20lang:java&#38;type=cs" rel="nofollow">http://code.google.com/codesearch#search/&#38;q=%5Cw%7B60,%7...</a><p>E.g. TraversableResolverSpecifiedInValidationXmlNoDefaultConstructorGwtTest , DeleteContentTypeXmlDocumentResponseDeleteContentTypeXmlDocumentResult , and so on.
评论 #4771107 未加载
评论 #4771239 未加载
评论 #4771039 未加载
javajoshover 12 years ago
This is not a code smell, but something larger, and much worse. Java is fundamentally an imperative language, and these names are evidence of the disconnect between that nature and what people <i>think</i> Java is.<p>One can argue that this is the result of ignorance, that "good" Java programmers will avoid this trap. And yet, for all it's restrictions, it doesn't give much refactoring guidance. The proliferation of patterns (both for creation and relation) in Java is a weakness, not a strength, and the result is monstrosities like this. Training, experience and convention avoids these traps, but why do we create new languages if not to reduce the amount of training, experience and convention that a programmer needs to learn in order to be productive with an environment?
评论 #4771220 未加载
throwaway64over 12 years ago
My personal favourite comes from apple<p><pre><code> AVPlayer *player = &#60;#A configured AVPlayer object#&#62;; CALayer *superlayer = &#60;#Get a CALayer#&#62;; AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; [superlayer addSublayer:playerLayer]; </code></pre> <a href="https://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVPlayerLayer_Class/Reference/Reference.html" rel="nofollow">https://developer.apple.com/library/ios/#documentation/AVFou...</a>
jakubpover 12 years ago
I've only touched Java a bit, but AFAIK it has quite strict package hierarchy system that allows naming and grouping things nicely.<p>Why then people keep creating long class names in the first place? I get it that this particular example might be a generated name, but still, why not just create package hierarchy that represents the code properly?<p>Also wouldn't using package hierarchies automatically lead to a bit better design (more modular, more understandable)?
评论 #4771060 未加载
评论 #4771249 未加载
评论 #4771008 未加载
评论 #4771609 未加载
twpover 12 years ago
You've most likely already seen this, but, if not, it's a relevant, great read: <a href="http://discuss.joelonsoftware.com/default.asp?joel.3.219431" rel="nofollow">http://discuss.joelonsoftware.com/default.asp?joel.3.219431</a>
评论 #4771186 未加载
anthonybover 12 years ago
Ah, naming things. One of the two hard problems left in Computer Science.
评论 #4770969 未加载
评论 #4772170 未加载
ww520over 12 years ago
Some people like to document their code with long name instead of comment. It's an internal class anyway. Why would anyone care?<p>JDK has a superb auto document building tool to extract all the classes in JavaDoc and letting people to find internal classes easier.
orangethirtyover 12 years ago
I think Javascript also suffers from something like this: functions inside functions inside functions inside functions. If Java is the king (queen?) of horrible naming conventions, Javascript is the prince(ss) of horrible code structure. It might be why both are named Java...<p><pre><code> var foo = function(foo, bar){ var bar = function ( function (x) { this.something = function (z) { return function (y){}}}}}; //or something like that. Only a fool would think the code above is real or even correct.</code></pre>
评论 #4771749 未加载
gkobergerover 12 years ago
More information [2007]: <a href="http://www.pushing-pixels.org/2007/11/07/and-the-longest-jre-class-name-is.html" rel="nofollow">http://www.pushing-pixels.org/2007/11/07/and-the-longest-jre...</a>
joshfraserover 12 years ago
Or ififtpiftpmbp as I like to call it for short.
评论 #4770957 未加载
1010011010over 12 years ago
When I saw the title I thought, _that has to be java_. If it had included a "Factory" or "Manager" in there somewhere I would not have needed to look at the link to verify.
评论 #4771522 未加载
huskyrover 12 years ago
This was obviously generated using the Enterprisify your Java Class Names tool:<p><a href="http://projects.haykranen.nl/java/" rel="nofollow">http://projects.haykranen.nl/java/</a>
endymi0nover 12 years ago
I think this Class looks okay, but it's definitely still lacking an AbstractProxyInstanceFactoryDecorator.
bjculkover 12 years ago
Never mind the fact that this is in the com.sun package, and as such should never really have to be dealt with. However, I do agree that anyone who makes a class name longer than three or four words is somewhat demented.
jongalloway2over 12 years ago
I'm pretty sure this was generated by a Hidden Markov Model gone haywire.
abrknover 12 years ago
<p><pre><code> com. sun. java. swing. plaf nimbus, Internal Frame? Internal Frame! Title. Pane... Internal Frame. Title Pane Maximize Button Painter.</code></pre>
krobover 12 years ago
Wow, think they could make that any longer? I mean, I don't think it was long enough. 78 characters isn't long enough, I think it should be at least 96.
评论 #4772175 未加载
drawkboxover 12 years ago
They should have run it through the class namer: <a href="http://www.classnamer.com/" rel="nofollow">http://www.classnamer.com/</a>
Cieplakover 12 years ago
Reminds me of the FactoryFactoryFactory pattern.
dschiptsovover 12 years ago
<a href="http://karma-engineering.com/lab/wiki/Programming" rel="nofollow">http://karma-engineering.com/lab/wiki/Programming</a>
bjhoops1over 12 years ago
Not sure whether to laugh or cry about this.
bbayerover 12 years ago
creating inheritance by using name conventions is really good idea!!
mudumhover 12 years ago
really long name!
Evbnover 12 years ago
Yes, let's all make fun of Java because it can be used to build (and then name) things we don't know how to make.
Mamadyover 12 years ago
Why? Because Java is awesome.<p>But seriously, this just highlights one of the downsides of following "coding standards" religiously.
评论 #4771044 未加载