323 points · by heydenberk · 14y ago · 150 comments
InternalFrame InternalFrame
Title Pane,
Internal Frame
Title Pane.
Maximize Button Window,
Not Focused State.
http://stackoverflow.com/questions/1697215/what-is-your-favo...The moderation system on stackoverflow is broken because an unskilled user can gain high reputation by getting upvotes from other unskilled users (I've seen a lot of wrong answers getting up-votes). This means that over time the average level of skill in the people moderating the site drops and you end up with a lower quality of moderation.
http://www.stackprinter.com/export?question=1697215&service=stackoverflow
But you cannot link to individual answers there, sadly. It's the second one, though. InternalFrame InternalFrame
We should be able to make this fit with "Silver Bells."Vogon poetry, to be specific.
About 1000 functions in all (so that's just the globals), of those a hundred have names > 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.
There are only 2 things hard in programming, cache invalidation, naming things and off by one errors.
Personally I think this name is bad because in spite of the enormous length it still doesn't tell me what it actually does. It just uses a lot of characters to indicate its spot in a hierarchy.
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.
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.
The things that can help you to extend your runway a bit in this respect are:
- be consistent
- reduce scope wherever possible
- pick short names for primary objects
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.1) Most of us never tackle specific problem domains that are very rare
2) Most of us never come up with real world solutions
Most of us these days work on CRUD web-app with only a few who actually go deep into specific problem domains.
Sometimes the problem domains is just that hard. I know there are optimistic developers out there that keep saying "I can simplify this particular problem domains" but here we are in 2012 still writing CRUD web-app.
No. That is just wrong. There is no problem domain that requires the use of very long strings to refer to individual pieces of it. All systems, either statically or dynamically, can be decomposed into smaller pieces who's names are short because they are meaningful within the context of another name.
Or, to put it another way, you get names like this when you statically code a data-structure that should be dynamic.
It also implements a specific interface Painter<JComponent> which explains the Why and the javadoc is copied from its parent class.
So it is not as much an example of beauraucracy as of code-generation.
Alternative would have been hundreds of "AnonN" identifiers with N going well into the hundreds...
:)
The embedded error is, of course, in itself off-by-one, but the actual cause could be cache invalidation -- the list was extended from two things to three without updating the length counter.
(Excuse me if I've mentioned this before.) So, I met the guy who did the first implementation of Merge Sort which he wrote in assembly language on paper tape. One of his comments on C++ after noting how cluttered it could look: "So, is this today's equivalent of COBOL?"
> 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
Global namespaces are evil. We have non-global namespaces, but programmers keep on acting like there's only one global namespace. In reality, in large projects, everything should be considered relative to intersecting areas of concern, and code should always explicitly reference the libraries being used locally. Python could be used this way, but I suspect most programmers act as if imports are just a way of getting what they want into their most convenient namespace, which effectively becomes the global one.
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 (http://static.springsource.org/spring/docs/2.5.x/api/org/spr...) 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".
Take that, GoF.
Basically it's been deprecated, but its used for AOP interceptors. It gets a lot of flack, but there was a reasonable reason for the Spring developers to have created this class.
Oh, and the original documentation is pretty comical. But the latest documentation makes it very clear what it does:
http://static.springsource.org/spring/docs/current/javadoc-a...
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?
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.
http://msdn.microsoft.com/en-us/library/aa432714(office.12)....
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.
How would you name such thing?
[1] http://javadoc.bugaco.com/com/sun/java/swing/plaf/nimbus/pac...
I'm guessing this shouldn't even be exposed to anything outside of an InternalFrame anyway.
The rest of the world might simply say blah.bah.frame.paint and be done with it.
[1]http://weblogs.asp.net/rchartier/archive/2004/02/05/68350.as...
Interesting. It's long, but it's also pretty clear on what it does, and doesn't have any repeated words.
Reading this, I would guess that it's a notification of when the user starts editing a column, and indeed that's what it does. "Informs the System.Windows.Forms.DataGrid that the user has begun editing the column." is the official description in the API.
Anyways, we are shaming Java here because of one obviously automatically generated internal class.
http://code.google.com/codesearch#search/&q=%5Cw%7B60,%7...
E.g. TraversableResolverSpecifiedInValidationXmlNoDefaultConstructorGwtTest , DeleteContentTypeXmlDocumentResponseDeleteContentTypeXmlDocumentResult , and so on.
These super long names not part of any client interface, no one is ever going to have to type that monstrosity except for the guy writing the test. But when you see the failing test output that prints the test name, you already know what is failing.
You can have a small class name and a (comparatively) long comment, or just a long class name. Considering there is now no need for a comment and the test name is actually useful for debugging failed tests easily (you don't need to "dereference" the short test failure name to get the surrounding comment), this style is actually a win.
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?
How many programmers have been affected by this internal class? How many programmers have used it and complain about it?
Java allows long identifier names and gives people the freedom to name however they like. Why is that a bad thing? You want syntax rules in the language to force short identifier names? We had those long while back and it's a really bad idea.
And BTW what is so wrong about imperative? It's simple to learn and simple to follow. It has solved many problems, given whatever the real world constraints. Just because functional is the in-thing now doesn't mean imperative is totally bad.
Nothing! The problems occur when people think that it's not.
And I really disagree with your hipster comment. You can indeed accomplish any task with Java, but that is damning with faint praise. The question is whether or not the environment gives the programmer adequate refactoring pressure to guide his decisions. Java provides almost no such pressure, resulting in a mess.
Many problems have been solved in Java despite of this, not because of it.
I don't really understand what you are trying to get at. Is it wrong or it isn't?
The hipster comment is spotted on. This post is evident of that attitude. The OP has to dig up an internal class whose name is probably generated to bash Java. And your original comment basically went further and claimed this long class name is the evident of what is so wrong with Java in general.
If there's no pressing pressure to refactor, then it has work well for its purpose. You want to limit class name to 8 characters to force programmers to pick shorter name? It's an internal class, for god sake. What's the impact on 99.99% of the programmer out there?
Development is a process of compromise and trade-off. Developers don't have infinite time and infinite budget to code. They have to pick their battle and do the more important things.
AVPlayer *player = <#A configured AVPlayer object#>;
CALayer *superlayer = <#Get a CALayer#>;
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
[superlayer addSublayer:playerLayer];
https://developer.apple.com/library/ios/#documentation/AVFou...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?
Also wouldn't using package hierarchies automatically lead to a bit better design (more modular, more understandable)?
There are java applications that have been around for decades. I've worked in codebases that are over twenty years old. Some of these systems are responsible for billions of dollars and have been heavily tested (the others are responsible for billions of dollars and have been barely tested).
Say you are a consultant, and you're working on a shipping application that has been around since the late 90's and is responsible for moving goods where the sum total of all items in transport over a year is larger than the GDP of Taiwan.
In that application there is a Warehouse interface. Simple thing, basically it has a receive() and distribute() method that moves product from one location to another (warehouse.receive(truck) or warehouse.distribute(200,truck)).
Around 2000 someone needed to create an edge case because specific warehouses are only available during specific times of the year. Like black Friday to Christmas. Usually it is too much overhead to keep all these warehouses running so they are only open 1/2 the year (this doesn't happen, but work with me). So someone created class TimedWarehouse that will do this calculation (on date X no longer receive).
Now it is 2012 and you are just a contractor. The big problem with the TimedWarehouse is at the end of the year you MUST VACATE ALL GOODS (because the warehouse is going to shut down). For the last couple of years product has been lingering in these warehouses keeping them open longer (costing more money).
The best way to handle this is perhaps a batch process job that sends emergency shipments as it gets closer to the end of the year. So something that cleans the timed warehouses out. Now you're just a consultant, you can't rework the entire framework but you must keep with convention... what to do
TimedWarehouseProcessor (nice... but doesn't indicate that it is only used towards the end of the year)
TimedWarehouseYearlyCleanout (makes more sense, but is terribly specific, what about warehouses that are open twice a year)
TimedWarehouseCleanoutManagementUtility (Bingo! More generic sounding, and it is a 'utility')
Imagine the poor sap who might need to extend that class. The process repeats over time. More contractors following the rules of convention, larger and larger class names.
AbstractTimedWarehouseCleanoutManagementUtility TimedWarehouseCleanoutManagementUtilityFactory TimedWarehouseCleanoutManagementUtilityConfiguration TimedWarehouseCleanoutManagementUtilityDto etc...
Maybe using underscores in class names would be nice, but then it gets ambiguous how to punctuate something, which gets annoying.
Some object-oriented programmers do something similar, where their programs are expressed in a domain-specific language written as an object relationship graph. Only they skip the part where that language is supposed to make it easier to solve the problem.
What do I mean? Here's my (somewhat ancient) attempt at parody: http://pastebin.com/TyNrvRmB
It has all the hallmarks of production code I've seen in this style: it's about 20 times more than the necessary amount of code, it's subtly buggy, and it needs explanation because what it does is completely non-obvious.
It is arguably slightly easier to extend than the obvious solution, but at a great cost, and in a silly one-off program at that.
The worst part? This doesn't scream parody in some circles. This is just how things are done, as if anything less involved is fundamentally broken.
This is precisely how good Smalltalkers operated. It was very doable, because even constructs like conditional logic and "looping" (really iterators) were just ordinary calls. For example, if you wanted to implement "fuzzy logic" in Smalltalk it would just take a mere minutes to implement some methods like:
ifTrue:ifFalse:ifMaybe:
Then define a Maybe class and use it as the Maybe value and park some methods like that on it. Then this would let you write code like: result
ifTrue: [ "condition 1" ]
ifFalse: [ "something else" ]
ifMaybe: [
"handle maybe"
].JDK has a superb auto document building tool to extract all the classes in JavaDoc and letting people to find internal classes easier.
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. com. sun.
java. swing.
plaf
nimbus, Internal
Frame? Internal Frame!
Title. Pane...
Internal Frame.
Title Pane
Maximize
Button Painter.But seriously, this just highlights one of the downsides of following "coding standards" religiously.