Making life better by not using Java web frameworks? [closed]
Asked Answered
A

12

49

I'm so tired of having to learn yet another Java web framework every other day.
JSP, Struts, Wicket, JSF, JBoss Seam, Spring MVC to name just a few - all this countless frameworks out there try to address the same issues. However, none of them really solves the fundamental problems - that's why there are still coming up more and more new ones all the time.

Most do look very bright and shiny on the first impression because they simplify doing simple things.
But as soon as it comes to the implementation of a real world use case one is running into problems.
Often the frameworks don't provide any help but are hindering one and limiting the options by forcing things to be implemented according to the frameworks own logic and environment.

In short, I see the following disadvantages when using a framework:

  1. There mostly is a steep learning curve and you first need to understand sometimes quite academic concepts and know meaning and location of a bunch of configuration files before you can get started.
  2. The documentation usually is more or less awful, either missing a public accessible online reference, is helpless outdated, confuses different incompatible versions or all of this together and often doesn't provide any helpful examples.
  3. The framework consist of zillions of classes which makes it practically impossible to understand the intended use only by browsing the sources.
  4. Therefore you need to buy some "XYZ in action for dummies in 21 days" kind of books which have a bad user interface because they are missing a full text search and are heavy to carry around.
  5. To really use one of this frameworks you need to learn by heart how things can be done the way the framework requires it by remembering the adequate classes and method names until your head is full of stupid and useless information you can't use for anything else.
  6. There is a big overhead, slowing down your applications performance and making your brain feeling numb when try to understand what really is going on.
  7. In the real world there is usually no time to get well familiar with something new because of the pressure of being productive. As a consequence of this learning by doing approach one always looks only for the fastest way to get the next task done rather than really understanding the new tool and it's possibilities.
  8. The argument that following a standard would allow people who are new to a project to quickly get started is not valid in my view because every project uses a different framework even within the same company (at least in my case).

It seems to me that the following quote from Albert Einstein fits here very well:

“We can't solve problems by using the same kind of thinking we used when we created them.”

Back in my good old PHP coding days when coding still was fun and productive, I used to write my own frameworks for most things and just copy-pasted and adopted them from one project to the next.
This approach paid out very well, resulting in fast development, no overhead at all and a framework which actually was mightier than most Java frameworks out there but with only a few hundred lines of code in a single file plus some simple mod_rewrite rules.
This certainly wasn't solving all problems of web development, but it was simple, fast and straight to the point.
While perfectly adjusted to the requirements of the current project, it also was easy expandable and had a very high performance due to zero overhead.

So why all that hassle with using this frameworks, why not throwing them all away and going back to the roots?
What should I say to my boss when we're starting tomorrow the next project with a new framework again?
Or are there maybe frameworks which really make a difference?
Or some hidden advantages I have ignored?

Ancheta answered 23/4, 2009 at 10:49 Comment(9)
It sounds like you're ready to make the switch to Ruby on Rails!Hamamatsu
Well, whatever floats your boat. But I prefer to leverage the power of millions of man hours of hard work by using of tried, tested, proven and broadly understood frameworks which provide highly configurable solutions to complex problems, which in turn allow me to focus on my problem domain.Kirk
Which frameworks are you talking about?Hamamatsu
You should check out the Stripes framework :)Adest
Tapestry 5 looks very promising for me. I believe that component oriented frameworks can make a big difference. You can read Tapestry 5 comments here: nabble.com/…Desertion
Well, that's interesting: I found that argument in several answers that someone else put more time into something than I could have. But now, what kind of metric is that? Taking the working time which has been spend to measure the quality of something is as stupid as paying by lines of code per day. If all the time is spend only to further blow up some framework which already consists of more than 1000 classes - how's that improving the quality when only more complexity is added?Ancheta
Why don't you port your framework to Java then?Hiller
You should have a look at Play Framework - it's a Java Framework inspired by Ruby on Rails. It has a very short development cycle, just save the file and update your browser.Putup
Think about your fellow developers, now they have to learn your framework which is properly not documented and they cannot move on at all!Garth
A
13

Here is a quote from Kev from the thread What’s your most controversial programming opinion? which fit's in here really well:

I think that the whole "Enterprise" frameworks thing is smoke and mirrors. J2EE, .NET, the majority of the Apache frameworks and most abstractions to manage such things create far more complexity than they solve.

Take any regular Java or .NET OMR, or any supposedly modern MVC framework for either which does "magic" to solve tedious, simple tasks. You end up writing huge amounts of ugly XML boilerplate that is difficult to validate and write quickly. You have massive APIs where half of those are just to integrate the work of the other APIs, interfaces that are impossible to recycle, and abstract classes that are needed only to overcome the inflexibility of Java and C#. We simply don't need most of that.

How about all the different application servers with their own darned descriptor syntax, the overly complex database and groupware products?

The point of this is not that complexity==bad, it's that unnecessary complexity==bad. I've worked in massive enterprise installations where some of it was necessary, but even in most cases a few home-grown scripts and a simple web frontend is all that's needed to solve most use cases.

I'd try to replace all of these enterprisey apps with simple web frameworks, open source DBs, and trivial programming constructs.

Ancheta answered 24/4, 2009 at 9:17 Comment(0)
P
35

Back in my good old PHP coding days when coding still was fun and productive, I used to write my own frameworks for most things and just copy-pasted and adopted them from one project to the next. This approach paid out very well, resulting in fast development, no overhead at all and a framework which actually was mightier than most Java frameworks out there

Forgive me for believing that not one second.

but with only a few hundred lines of code in a single file plus some simple mod_rewrite rules. This certainly wasn't solving all problems of web development, but it was simple, fast and straight to the point.

So basically you developed your own framework over the course of months or years, tailored to your own needs, and could work very fast with it because you knew it intimately.

And yet you can't understand why others do the same and then try to turn the result into something useable by everyone?

Where's this great framework you developed? If it's so powerful and easy to use, where are the dedicated communities, thousands of users and hundreds of sites developed with it?

every project uses a different framework even within the same company (at least in my case)

Well, that's your problem right there. Why would you throw away the expertise gained with each framework after each project?

The idea is to choose one framework and stick with it over multiple projects so that you get proficient in it. You have to invest some time to learn the framework, and then it saves you time by allowing you to work on a higher level.

Pachston answered 23/4, 2009 at 11:18 Comment(9)
I have worked on too many projects where people thought writing their own controller was a good idea. And their own ORM solution, kinda. And maybe their own little templating language. IMO, even a crappy, but standardized abstraction from bare PHP or Servlets helps. +1Hepatica
I bet that while the guy who developed his own framework thinks "gee this works great!", any of his coworkers or anyone who has to touch the code down the line ends up thinking "great this guy re-invented the wheel, again..."Spaceless
You're missing the point. The strength of an own solution is that it doesn't try to cover all web application needs out there and therefore it's not be usable as an general purpose framework. It is much simpler to get a single purpose solution well done and bug free than a god-framework which can do everything except explain how to use it.Ancheta
You'll still end up reinventing the wheel (i.e. re-doing the bad design decisions and re-implementing and fixing the bugs) with many aspects that the "god framework" has long since solved well. Overall, unless you're working on tiny projects, or ones that are extremely unconventional, you still save a lot of time and get much better quality by learning and using a good framework than doing it yourself. No matter what your cowboy coder instincts say.Pachston
"No matter what your cowboy coder instincts say." Point taken :) I think the answer to my question is pretty much in what PhiLho is saying: "resolving common problems without getting in the way". As soon as a framework start's forcing you to do things in a certain way, it's limiting it's own advantages and introducing conflicts and incompatibilities with other parts of the application and other frameworks.Ancheta
"The idea is to choose one framework and stick with" sure, that's the idea, but does it work? Different projects = different requirements. Is there one silver bullet framework then why are not all using that one?Ancheta
I think a major reason for the large number of competing frameworks is evolution. They really are getting better - and then the good framework with a large userbase is competing with a newer one that may be better, but people are reluctant to give up their time investment.Pachston
And actually, I think "forcing you to do things in a certain way" is not a bad thing at all. Total freedom means most of all the freedom to make mistakes - and often also a lot of work establishing your own structures. I believe Rails and its "convention over configration" approach has proven that forcing you to do things in a certain way con drastically improve productivity without unduly limiting what you can achieve.Pachston
@dankoliver: It looks like frameworks provide perfect, well-tested and secure solutions to many problems, thus saving a lot of time. At the same time they create other problems which cost even more time.Svetlana
C
20

The problem with coming up with your own framework is that you will make all of the same mistakes that all of the established frameworks have already stumbled on and addressed. This is true particularly when it comes to security.

Just ask Jeff and the guys about what they had to consider when implementing the WMD in stack overflow. I'd rather use what they have produced in a project rather than implement it from scratch. That is just one example.

Cement answered 23/4, 2009 at 11:23 Comment(4)
"you will make all of the same mistakes that all of the established frameworks have already stumbled on and addressed" I wish I could vote more than once for thisSpaceless
Of course I need to deal with the very same problems when I develop my own solution. But I can solve them in the way that best fit's my specific project requirements without much need of generalization. I'm implementing only what I really need, instead of implementing everything what someone at some day possibly could need and therefore the own solution has less complexity and is also easier to secure.Ancheta
The problem is that the mistakes you will make are not obvious and you might not even know any issues exist unless someone with experience points them out. Again, I point to security as an example. It's very hard to get right on your own.Cement
"The greatest mistake you can make in life is to be continually fearing you will make one." ~Elbert Hubbard I insist that it easily is much more dangerous to trust a framework which you don't know and understand in depth because of it's complexity and from which you anyway need only a small fraction of it's functionality.Ancheta
A
13

Here is a quote from Kev from the thread What’s your most controversial programming opinion? which fit's in here really well:

I think that the whole "Enterprise" frameworks thing is smoke and mirrors. J2EE, .NET, the majority of the Apache frameworks and most abstractions to manage such things create far more complexity than they solve.

Take any regular Java or .NET OMR, or any supposedly modern MVC framework for either which does "magic" to solve tedious, simple tasks. You end up writing huge amounts of ugly XML boilerplate that is difficult to validate and write quickly. You have massive APIs where half of those are just to integrate the work of the other APIs, interfaces that are impossible to recycle, and abstract classes that are needed only to overcome the inflexibility of Java and C#. We simply don't need most of that.

How about all the different application servers with their own darned descriptor syntax, the overly complex database and groupware products?

The point of this is not that complexity==bad, it's that unnecessary complexity==bad. I've worked in massive enterprise installations where some of it was necessary, but even in most cases a few home-grown scripts and a simple web frontend is all that's needed to solve most use cases.

I'd try to replace all of these enterprisey apps with simple web frameworks, open source DBs, and trivial programming constructs.

Ancheta answered 24/4, 2009 at 9:17 Comment(0)
I
11

The problem is of course not just with Java frameworks. I've lost count of the number of C++ MFC projects I've seen floundering around trying to shoe-horn their requirements into the Document/View model (which really only workks for text and graphic editors - database applications are particularly difficult to shoehorn).

The secret of succesful framework use is to change your application to match the framework, not the other way around. If you can't do that, don't even think of using the framework - it will end up being more work than if you had written the app from scratch with the help of some good, reliable and well-documented utility libraries.

Indusium answered 23/4, 2009 at 11:24 Comment(1)
+1: good point. Either choose a f/w and then build the application to match the f/w or choose a f/w that matches your architecture. Don't shoehorn an application into a f/w if it creates a huge impedance mismatch. That is recipe for failure.Glasswort
C
9

So are you saying we should deal in sockets and HTTP every time we want to build a web application!

The servlet container itself can be considered a framework, since it handles all these messy details, and leaves you to write much simpler Servlets/Filters/Listeners (ie: 'extensions' of the framework specific to your application).

All any framework tries to do is separate mundane, repeatable, error-prone, legwork code from the fun application-specific code.

However, for a small application, you can get away with simply having a Model 2 MVC approach which uses only JSPs and Servlets.

Example:

class MyController extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ... {
        MyBean model = // do something
        request.setAttribute("model", model);
        request.getRequestDispatcher("/view.jsp").forward(request, response);
    }
}

Then as your app becomes more sophisticated, you could look at using Spring MVC to provide looser coupling (and hence more flexible) of controllers, view resolvers etc..

Colner answered 23/4, 2009 at 12:18 Comment(1)
Model 2 sounds interesting. I have been playing with Spring MVC and enjoying the design of the framework, but I wonder how much it is giving you over the Model 2 (aside from Spring injection). Detailed information on the pattern seems a little scarce but I did find this one article, javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.htmlKelliekellina
D
7

I share your pain when confronted with yet another framework that doesn't do the trick.

Having survived ten years of jsp, struts, EJB, EJB2, struts2, jsf and now more recently all the new web services framworks, the xslt horrors and wsdl-first nightmares, I am definitely fed up.

There is a number of problems with frameworks. They leak so you have to learn more -not less, inhouse frameworks have huge costs, using external frameworks costs too (but much less), as they seldom deliver, and then you end up writing enourmus chunks of xml-configuration and spend days correcting case and spelling errors that you had seen immediately in your favorite content helping code editor.

Maybe the answer is to find less pompous toolkits that tries to solve a problem but not redefine the world, but that is hard too as the fundamental application model (html over http) is awkward - at best.

Add the fact that there seems to be a lot of complicators around, people that seems to be obsessed of trading boring simple problems to complex (but hard) interresting problems ( maybe a variant of Eric Sink’s Axiom of Software Development mentioned above.)

Add the hubris of developers that knows it all and do not hesitate to write a new framework to solve all the hard problems for you, Only that they can't, leaving 10% left, only much harder to fix now.

I have no .NET experience, but the .NET world seems to be less crowded with theorists and complicators, and maybe the lingering stink of VB is scaring them off, but everytime I hear someone telling me that they have spent 1500 hours on their maven config (hello?), I am seriously considering deleting "java" from my resume.

...what was the question again? Are there any frameworks that make a difference?

EDIT - added Stripes and QueryDSL.

I would try Stripes or GWT with QueryDSL + Hibernate or OpenJPA (with annotations) just for the fact that you actually develop in Java, and try to limit the use of wsdl-first web-services, xml-centric frameworks, EJB and ESBs (not the beer) as much as possible.

Delores answered 23/4, 2009 at 14:24 Comment(3)
Have you tried Spring Web Flow? I'll admit, the flow definitions you create are all in XML, but they are usually quite small, and the syntax is actually quite sane. It uses a domain-specific language in XML, and models web app flow as a state machine consisting of states (view, action, decision, subflow, end) and transitions between them. Take a look.Prerequisite
+1 for the 1500 hours on the maven config laugh.Pipkin
Thanks for the tip. I doubt that I would enjoy working with yet another domain specific language expressed in xml.Delores
C
3

I once had to work on a project trying to implement it in JSF. It was a nightmare.

Most of the working time was spent to just making things compile. The fact that no less than half of what was compiled didn't work was another story. Almost no tutorials. Documentation is basically an automated source code export with no human comments. How can one be expected to work like this?

Of several frameworks we'd seen only Sun's was able to create a new project that is compilable at all! The other could only produce bunch of stuff it took many days to ring to a compilable state.

The web was almost silent. To any search there we no more than 20 pages of search results, with useful first 1-3. In that relevant what was found, a half of people was crying for help, the other half declared they had cried for help, noone came, they lost time and interest and dropped that technology.

So we spent times and only made something simple that could have been done in a few weeks with ASP.NET for example.

Then we looked at alternative JSF frameworks. To our surprise we found them all quite incompatible.

With not surprise at all, we joined the ranks of those who dropped JSF as well.

Campy answered 23/4, 2009 at 11:33 Comment(1)
JSF isn't too bad...as long as you try to confine it to the view. I try to stay as far away from phase listeners, component binding, custom converters, managed beans, and its horrid navigation as I can. I'm using Spring for IoC and Spring Web Flow for the controller. So far, SWF is the sanest web framework I've seen...though I have to admit the only other experience I have is with Servlets, Struts, and JSF.Prerequisite
K
3

Consider the counter point. I am working at a shop right now that doesn't use any frameworks beyond the JSP standard. Everyone has a different way of doing things and we are very lax about concepts like de-coupling and security concerns like validation.

While I don't think use of frameworks automatically makes you a better coder, I do think by using a standard design pattern implemented by most frameworks and by having easy access to utility functions like validation, I think the chances are you are going to be forced to code up to a certain standard.

In web application design you aren't inventing the wheel every time, so you either end up rolling your own solution to common tasks, or using a framework. I make the assumption that by using a commonly used framework rather then roll your own, you are going to get underlying code that is well tested and flexible.

There is nothing wrong with rolling your own solution as an academic pursuit but I accept that there are people out there putting a lot more time into a robust solution then I may be able to spend. Take log4j for example, pretty easy to roll your logger, but log4j is well tested and maintained and they have taken the time to improve on flexibility and performance to a degree that most roll your own loggers can't touch. The end result is a framework that is robust but also simple enough to use in even the most basic applications.

Kelliekellina answered 23/4, 2009 at 15:47 Comment(0)
M
2

What worked for me is: you shouldn't just learn any web framework you hear about, take a look at it, see if it makes you code comfortably, ask around stackoverflow or forums to see its advantages and disadvantages, then learn it and learn it good and just stick with it until you feel its broken or plain outdated. Any of the webframeworks you wrote about is good by itself and a fun to work with if you "REALLY" know what it does. if you don't you are just wandering in a desert with no compass! I've also found the 21 days book is a sure way for you NOT to master a framework or a technology. Docs is surely something to consider while adopting a f/w it also helps if you look around the code yourself (actually this is what helps me the best when I faced with some behavior that I find wierd.

1-So why all that hassle with using this frameworks, why not throwing them all away and going back to the roots?

if you go back to the roots you rewrite code that does the same thing again and again + most of these f/ws being open source means they are probably better off with maintenance than you would do alone to your own f/w.

2-What should I say to my boss when we're starting tomorrow the next project with a new framework again?

this is my first time working with this f/w I don't see why should we use this f/w I already know X and I am really good at it. bare in mind the cost of me learning this f/w, the cost of rework that has to be done due to my ignorance of such a f/w. I think we are better off using X, if this is a specific requirement we should fight for it and only do it if we really have to stating the previous notes.

Or are there maybe frameworks which really make a difference?

only those who address the way you think not the way you write code (think struts at its golden age enforcing the MVC pattern).

Or some hidden advantages I have ignored?

can't think of any tbh.

Mom answered 23/4, 2009 at 11:15 Comment(1)
Maintainance... Go for those frameworks backed by a specification....Hiller
A
1

You have the same problem in PHP: more frameworks than you have fingers to count them on, each being the best and greatest (although you have some hints: pure PHP5 design vs. PHP4 compatibility, Rails philosophy (inflexible folder hierarchy, auto-generated code) vs. library approach...) and you spend more time searching and exploring the possibilities than writing your code!
But in PHP it allows to pre-solve common problems, like I18N support, integration of plugins, management of sessions and authentication, database abstraction, templates, Ajax support, etc. Avoiding to re-invent the wheel on each project, and to fall in common traps for newbies.

Of course, there are some hints for Java frameworks too: big or small? well documented or not? widely used or confidential? for XML fans or not? Etc.
I suppose most frameworks aim at large projects, where learning time isn't a big problem, scalability and ease of deployment are important, etc. They are probably overkill for small projects.

There is also a trend in such frameworks to aim at doing a consistent set of loosely coupled libraries rather a monolithic framework. That's the case, in the PHP world, for the Zend framework (some even deny the usage of word 'framework'...).
So it solves the issue of "resolving common problems" without getting in the way.

Aromaticity answered 23/4, 2009 at 11:18 Comment(1)
"resolving common problems without getting in the way" - I think this is a very good point! This is exactly what annoys me with the Java frameworks I've worked with, they're getting in my way! There is a certain arrogance I've often found in the Java world: Sun's Java architects as well as many framework programmer seem to think they would know better than you and hence are forcing you to do things in a certain way rather than giving you tools you can use the way you want to or need to.Ancheta
T
0

However I disagree on some points that you have mentioned but I agree with you regarding the boring work.

Yes all web applications are about pages displaying forms, collecting data, making validation, sending the data for storage in Database, and filtering the stored data by search forms and displaying the result in tables and selecting one or more records for manipulation (CRUD, or business actions that all about changing status in database).

however I'm working for just 4 years plus of course my 4 years academic study. I feel this type of development is boring as you are not inventing algorithms, off course you got happy when you discover new framework and will be happier if you integrated one of the AI engines into your application, but at the end I feel that this work is dummy works, or lets say machine work, so why we don't automate all of this stuff.

yes another framework ;) MDA Model Driven Architecture, in brief is about transforming from PIM (Platform Independent Model) to PSM (Platform Specific Model), i.e for example from UML to Code.

And this may solves your problem of learning curve and technology changes as you will only need to be good at modeling, as there are some frameworks that implements the MDA specs such as AndroMDA as it have cartridges that take the Class Diagrams, Use cases, Sequence Diagrams, and Activity Diagrams and generate Database creation script, POJOs, hibernate mapping, Spring/EJB, JSF/Struts, .NET code.

Off course such frameworks will not generate 100% of the code but will generate a big percent, and off course you will ask whither this framework will solve complex and tricky scenarios of requirements? today I will say no, tomorrow yes.

so why you and I don't invest in the development of this great framework.

Tyndareus answered 23/4, 2009 at 11:22 Comment(5)
MDA is just another in the decades-long string of fairy tales about new technologies replacing the task of writing code with something so easy anyone can do it. It doesn't work, and it never will. If your model is detailed enough to generate all the code, you'll spend twice the time modelling as if you'd just written the code, and if it doesn't generate all the code, what's the advantage over frameworks that just allow you to write only the non-repetitive code?Pachston
MDA using UML is a joke. maybe for something quick and dirty it is ok. but it is much better to have your own model with its own language than trying to embed your own language inside of UML language.Chiapas
Michael: the benefit/advantage of spending too much time as you said (spend twice the time modelling) over frameworks is that you are independent of the language, you can use the same model to generate the whole system in PHP, or even .NET not just changing the java frameworks (Spring <--> EJB), or (JSF <--> Struts).Tyndareus
drscroogemcduck: who said that you will embed your own language inside of UML, you are modeling independent of the language you shouldn't know think about the language while you are modelling.Tyndareus
Engineering is all about using resources. If you don't like web frameworks you will just have to be more resourceful.Abrego
H
0

So you think it's better if we all invent the wheel in every project?

You might see an excess of frameworks as a problem, and it does make it harder to choose your own set. But on the other hand, you don't have to try each one; and even if you do, you'll end up preferring some of them. You will have a favorite framework for ORM, another for web development, IoC, etc.

It does help to read up on some forums to learn which are the most popular ones; they must be popular for a reason, and even if it's not the right reason (like being technically superior, maybe it's popular just among managers because of the buzzword overload or whatever), knowledge of said framework will be helpful because you will be able to participate in several projects that use it.

Plus, using a framework instead of writing your own will save you a lot of problems. Bugs are not always found and solved by the authors; that's often done by users of the framework. You said you ended up with your own private framework in PHP; I bet it wasn't bug-free, but maybe you didn't know it since you were the only user and the only coder.

Hord answered 23/4, 2009 at 14:53 Comment(1)
Yes, if I need a different kind of wheel than I could reinvent it - why not? But if I need a similar wheel then it's just copy paste and parameterization. And if I need different wheels every other day then I'm going to invent the next wheel more flexible. So what? There is another point in that. Every time I reinvent the wheel I learn something and there is the chance that I'll possibly improve my coding skills with time. But what do I learn if I only glue awkward puzzle pieces together?Ancheta

© 2022 - 2024 — McMap. All rights reserved.