Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In his defense, I don't think the long class name is the problem he's pointing out.. it's the over-patterned, over-generalized nature of something that barely does anything.

The class's description is "Convenient proxy factory bean superclass for proxy factory beans that create only singletons."

Seriously? That's fucking hilarious.



My favorite part is that the first word is "convenient." At the point that you need this class, absolutely nothing about the situation could possibly be considered "convenient."


Oh totally. I'm enjoying believing that this commit was part of a patch submitted with the explanation:

"Added a new superclass because you wouldn't believe how hard it was to to create beans that create beans that create only singletons!"

Turtles all the way down.


Yeah, that would be amusing if it was accurate. Only that's not what it does. It is actually a way of extending the bean creation part of the framework that produces singleton scoped proxy objects.

I'm curious: what would you name that class?


I can assure you I wouldn't name that class.

But honestly, I'm kidding around. I'm not arguing the class is silly, or poorly named. I bet it's perfectly named. I'm not arguing the author did a bad thing here, I'm sure he or she did something awesome. All I'm saying is that the context that makes writing that class description necessary is totally hilarious.

Let's just agree on that. It doesn't mean Java sucks or Spring sucks. Big complicated projects sometimes lead to pretty wacky situations and we ought to be able to laugh at them. I'm certainly not suggesting other languages don't have the same culdesacs of lunacy.. they totally all do. Can you imagine the number of times someone's posted "Everything that's wrong with Perl in one line of code" ?

I really don't see any reason to take this stuff so seriously.


The context makes it entirely appropriate. A FactoryBean allows you to construct complex objects, or construct objects Spring can't easily create itself (e.g. JndiFactoryBean). A ProxyFactoryBean builds Spring AOP proxy beans.

As it turns out, there was no need for the class as it has been deprecated. However, providing an abstract singleton scoped proxy factory bean is indeed convenient. If there was a need for a factory that creates AOP proxies then it would be very useful to have an abstract class that implements most of the methods for you, and create them with singleton scope. In that case, AbstractSingletonProxyFactoryBean is sensible.

It's a corner case. It was used by one class, but that was deprecated later, so this was deprecated as there wasn't really a need for the convenience class.

I take this lot of stuff seriously because I see a lot of ignorant pattern bashing by those who haven't taken the time to understand why patterns are very useful and potentially can make OOP code cleaner and easier to maintain.


For the record, I spent 10-12 years coding Java (the last 4 or so w/ Spring). Lots of OOP, lots of pattern based enterprisey big boy stuff. I definitely have a solid (but atrophying) understanding of the concepts. I get that they're the right way to do big Java apps. But Java makes implementing them fucking laborious. Back when that was all I knew, it seemed elegant and I was used to the scaffolding.. but the truth is that in a number of other languages the same patterns require so much less scaffolding and even thought, that we don't even notice them. They're a given.

I give my users vastly more value-per-line-of-code now than I ever did writing Java.

That said, I have nothing against Java or folks that enjoy doing it... but even when it was a language that I was knee deep in and stoked on, I was able to laugh at some of the shark-jumping complexity of these cartesian products of patterns that would arise.


That's sort of the point of the class in question: use it derive your own class an you've extended the Spring framework...


If you spent your life being inconvenienced by the things you made earlier to make your life convenient, you'll go to extraordinary lengths to make other things that seem to make your life convenient given all the inconveniences you've already created for yourself. It does not really compute that this is another inconvenience you're building for yourself that is going to need another convenient AOP driven bean thing that you will write in a few months to get around the nonsense you burdened yourself with in the first place. It also does not help that everyone (well, at least the people with the money) is buying it and forcing it down their developers throats. If they don't want it, there's always a bunch of guys who are cheaper and will take it....


I read that as sarcasm by the author. I refuse to believe anyone would word it like this without sarcasm.


...or it could be a common malady amongst programmer: inability to write clear documentation. I note that it's much clearer in the most recent documentation.


Given that Spring is mostly used via annotations or config files, yes this is indeed useful. It helps to know what you are criticising before you show your ignorance.

A factory bean is a class that creates factories. You'll almost never need to create your own as you normally use the ones Spring provide for you. And with annotations, you'll likely never even notice them.

A proxy factory bean is used for Aspect Oriented Programming in the Spring framework. AOP is a fantastic way of doing OOP. Try reading up on it before you knock it. Spring uses AOP via proxies. By using proxies, you don't need to inject bytecode via CGLIB, which while a totally valid way of doing AOP, adds another dependency to your project which you may not want or even need.

Singletons are used by default by Spring, which is an IoC (Inversion Of Control) container. An IoC container is extremely useful as it fully decouples classes from one another - the container handles the coupling and you merely set things such as object creation up via annotations or configuration. One of the considerations needed to be taken into account when using Spring for object creation is to decide whether each object is created once and once only by the factory bean, or if multiple instances should be created. You usually use a singleton bean in Spring - otherwise you have to introduce tighter bean coupling with other beans, which kind of defeats the purpose of an IoC container.

A bean is a JavaBean, which is a very simple but powerful convention used to allow reusable components in Java.

So what does this do? It's a convenience class used to extend the Spring AOP framework should you need to do so without having to make changes within the Spring framework itself. Almost no application programmers will need to use it. However, if you have a very particular requirement for AOP proxy bean creation that is not currently handled by the Spring framework (unlikely) then you will indeed find it useful, and I dare say it is, indeed, convenient.

In short, ignorance is OK. But mocking something in ignorance is pretty foolish, and your foolishness is on full display here.

P.S. incidentally, Spring is now well past v2.5 and in fact the current version is 3.1.x. It helps to read the most up to date documentation when trying to understand something in a framework. The description of the class in the latest documentation now reads:

  Convenient superclass for FactoryBean types that produce singleton-scoped 
  proxy objects
http://static.springsource.org/spring/docs/current/javadoc-a...


Stop it! You're killing me! I can't breathe!


Frameworks are not applications. By their nature they are more abstract. Don't judge the code as if it was something it's not.


Totally. I've worked on some frameworks, and I get that things get hairy supporting some really crazy general and re-useable concepts. I'm not even saying Spring is shitty, or Java is shitty or anything. I don't really care... but don't you dare tell me that class isn't hilarious, because it is.


I don't really care... but don't you dare tell me that class isn't hilarious, because it is.

I don't see anything hilarious about it.


Indeed, the class isn't hilarious. Perhaps the class name initially boggles the mind, but when you learn what it does not only does it make sense, but you probably would be hard pressed to find a better name!



Hah. I'm not saying Spring is a good framework, I don't know it that well. But try building an app without any framework at all. Getting frameworks right is hard - they need to be abstract enough to be flexible, but not so abstract that you end up with a "general-purpose tool-building factory factory factory" when you want the framework to give you a hammer.


Yeah, but that's just an over-patterned object-oriented design. This has nothing to do with Java specifically.


Hardly. Firstly, AOP is a very effective and useful programming technique. It's used in a lot of places, and without it OOP would be considerably harder than it necessarily needs to be.

Secondly, this is a class used to extend the Spring framework unobtrusively if it is needed. Most likely you would never need it (if you are even someone who uses Spring, which I somewhat doubt... If you are then you should really learn more about the framework you use) but there are doubtless folks who may need it at some point for some super complex or out of the ordinary project you haven't even dreamed of yet.


well, but all java coders are this way. I'm working on a rails app built by java coders learning rails and it's, sadly, a pain in the ass, it's not that the code is malfunctioning, just that everything looks like it's a quantic mechanics equations when in reality it's just a 10 piece lego. Sure, they're not 100% is this way, but empirically I can state that, I too thought overengineering was beautiful when I was learning it, lame.


Seriously? That's fucking hilarious.

Only if you isolate it from all context. Within the context of how Spring is built and works, it's all perfectly reasonable. As cletus said above, if someone is going to slag Java, they should really pick something to pick on that is actually deserving.


And that has absolutely nothing to do with Java. Why is it Javas fault that some idiot decided to create such a class?


I guess there's a rule in place that hides the down arrow for comments in reply to my own or something. Anyways. I'd downvote if I could. The guy is almost certainly not an idiot. That's a rude, shitty thing to say.

Further, if you accept that Spring is a good idea (which in my opinion is equivalent to accepting that Java has major shortcomings that require something like Spring to overcome) then this class is likely plenty reasonable. Like other commenters have pointed out, frameworks are hard. Java makes them harder. In the context where Spring and Java are givens, I'm sure the author of the above is a very handy chap to know.

Be nicer.

[Edit: To be clear. I want to make sure there's no confusion that the point of my original comment was that the class is hilarious. Not that it's not justified, or that the author is foolish, or that Java is awful, or that Spring is awful. I don't have very strong opinions about any of those things.. other than assuming a committer on such a huge, demonstrably successful project is plenty smart and did the poor chaps who are in the unfortunate position of needing this class a great service.]


I've used Java for 10 years. I've never used Spring. I've never created an AbstractFactorySingleton. I've never used XML. There's nothing in Java that says you have to use anything in particular, apart from the runtime (Extremely solid), and the basic language syntax (IMHO nice enough).

OK, maybe they're not an idiot. Maybe it's warranted. I'd say it's probably over engineered stupidity though.

Even so, the title is like pointing to a stupidly constructed house and calling it "Everything that is wrong with bricks".


If you don't know what it's used for, or the purpose it was written for, then you aren't in a position to judge if it's stupid or not. I can assure you, it has a purpose, and that purpose is not stupid. The fact that the reason for the class is somewhat obscure and somewhat of a corner case does not make it unnecessary.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: