4 ms·
Over-complexity is common in the Java space. I was aghast at using JMS. You make a Context so that you can tell it to make a ConnectionFactory, so that you ca
by stcredzero 18y ago
Over-complexity is common in the Java space. I was aghast at using JMS. You make a Context so that you can tell it to make a ConnectionFactory, so that you can then ask that thing for a Connection, then you finally get to login. You can then instantiate Producers and Consumers and finally get messages.
Why do I need to have 5 different objects when one would do? Having 5 different objects did absolutely nothing for the client code except make it more complex. (And this actually complicates good coding for the user experience. When we notify the user of network problems, I have to add additional code to see if objects exist in the first place just to prevent exceptions.)
It would've made no difference if there was just one Object. (Except for shorter code.) I could use it to login to a server. I could use it to register interest in a topic then ask for messages on that topic. If I want to connect to a different server, then I could instantiate a second object. Why do I need 5 freaking instances to do the most basic thing possible?
- arockwell 18y agoThis also makes unit testing extremely diffcult since you have the joy of creating mock objects for your Context, ConnectionFactory and Connection. I have all but given up writing test code at work. The various j2ee frameworks I have to use make it almost impossible.
- st3fan 18y agoDrop Classic J2EE and learn Spring. It will make things sooo much easier and manageable.
- mattmcknight 18y agoIt definitely does make the above more manageable, but it doesn't solve the core problem which is that the whole design pattern is built for complete configurability, but without sensible defaults. In some sense, Spring only exists to manage the massive configurability of Java design patterns, but by adding it's own configurations to the mix. It's definitely a cool idea, but the better solution is to just avoid factory/context patterns. It's solving a problem most of us don't have.
- st3fan 18y ago"""It's solving a problem most of us don't have.""" I think that is because a lot of people simply don't know what good design is. I've seen many projects where people think they don't need Spring but where it made 100% sense. And made the project simpler and easier to manage and test. Even in small projects it makes a lot of sense to have a good seperation in layers or services and to use a mostly invisible helper to glue things together. Modern Spring can configure your app with a very minimal amount of XML. If you don't like XML then use annotation based configuration. I totally disagree with your statement that Spring only exists to manage the 'massive configurability of Java design patterns'. The only patterns that the foundation of Spring introduces are IoC and 'configuration by convention'. Those have been proven to be extremely powerful patterns that simply allow you to burn half of the 'J2EE Design Patterns' books.
- arockwell 18y agoSpring is definitely an improvement, however we had a serious problem getting it up and running in our environment (it was a while ago so I can't remember what it was exactly) and had to give up on it. It really does not help that all of our web projects are struts 1 and we have still have a fair amount of torque projects hanging around.
- megaduck 18y agoNo kidding. J2EE is an abomination, and is almost single-handedly responsible for destroying Java's reputation with a lot of programmers. Spring is a giant leap forward. Grails is basically Spring MVC, wrapped in dynamic language goodness. I'm using it for a project right now, and it's shockingly terse and clean. It's also a lot of fun, which is something I never thought I'd say about a Java "Enterprise Framework".
- dpifke 18y agoSpring's dependence on XML files always bugged the hell out of me. I like to be able to see what a piece of code does by looking at the code. Every time I tried to get excited about Spring I instead felt like at I was more and more at the mercy of my IDE.
- st3fan 18y ago"""Over-complexity is common in the Java space.""" Yes, in a SPECIFIC area of the Java space. There is a huge group of people who believe that J2EE and its complexities are a major pain the ass. That is why great frameworks like Spring, Guice or Stripes exist. Sun loves you when you use J2EE/JSF/EJB/JMS/JWHATEVER. But there are serious alternatives that are more lightweight, easier and less intrusive. Of course you will not add value (read: buy into) to the Sun Enterprise Ecosystem :-) Staying away from (most) 'Enterprise' Java standards has worked very well for me. I really enjoy working in Java.
- jm4 18y agoHave you seen Spring lately? I'm not sure it's much of an improvement. Stripes is nice as far as Java web frameworks go, but it's fairly simple and this is where the problem lies. Someone comes up with a tool that's great for a specific job. Later, someone else comes along with a slightly different problem and the tool changes a little to accomodate them. Then a few others. Before you know it every feature under the sun is added to handle every possible scenario. Now you're stuck with crappy middleware. It does a decent enough job after you configure it properly and strip it down to only the modules that apply to your specific problem. It's not so bad because you've been using it for a while and you know it inside and out. Plus, it can be used to solve everything. It can probably even cure cancer with the right module and proper configuration. But sooner or later someone else comes along, decides this nifty universal tool is a steaming pile of shit and sets out to invent something simpler and less bloated. And it will only be better because it doesn't have everything, including the kitchen sink, bolted onto it. It's focused and lean. But then someone comes along with a slightly different problem than what it was intended to solve and the hot new framework with all the buzz starts going bad just like the last one. Look at Stripes. It's just a better version of Struts2 which was based on Webwork which was intended to be a better Struts 1. Eventually, more and more cruft will be added to Stripes so it becomes as bad as what it was designed to replace and someone will come along and invent a better Stripes. In my opinion, this is the biggest problem with frameworks. Many developers prefer to have a universal tool instead of having several that are good for different jobs so we end up with this cycle of cruft.
- 18y ago