views:

584

answers:

12

I've done lots of java web development using jsps and servlets, and I have found this approach to be straightforward and flexible. Some of the groundwork involved though - such as managing database connections - is rather tedious, and it takes a fair amount of work just to get a new web app off the ground.

I'm therefore considering using a framework for the first time, but my impression of frameworks is that they're mostly used for large J2EE applications and involve a lot of complex configuration. What I'm looking for is something simple that (after the initial learning curve) will enable me to get up and running with a new web app as quickly as possible.

So my question is - does it make sense to use a framework for a simple java web app?

Note that I'm not asking which framework to use (if indeed a framework is recommended), as it has already been asked here.

A: 

I'd say use one - like you said, it's rather tedious to get stuff up and running for even a simple java web app. If the framework helps you get the job done faster and provides the services you need, I'd say it makes sense.

unforgiven3
+2  A: 

Yes it does make sense. Apps can grow and change and might require something a framework can provide easily in the future.

For example at my workplace we have simple jsp / servlet app. It needs to be rewritten just because of what I explained above. If someone would have taken the time to just get the framework setup we would be in better shape today.

mugafuga
+5  A: 

Yes, I would use a web framework for the following reasons:

  1. Increased navigation capabilities and controls. Even though you may not need them, they are there for you to use should you require them at any time
  2. As others have indicated, apps grow over time and you will feel the need for the framework at some point in time in the future. When you need to add additional pages and navigation
  3. Features that allow you to plug into other frameworks such as security and DB access frameworks. Spring is a prime example in the Java world. You never have to use Spring but it plugs in so well with Struts, Spring MVC, Hibernate, Acegi etc. It ends up saving you the hassle of doing all of the plumbing on your own.
  4. Support!!! Good frameworks almost always have a vibrant community to support them and ask and answer questions.

It may seem like too much hassle initially but definitely saves you much time in the future

Deep Kapadia
+3  A: 

I'd say it actually matters quite a lot which framework you go for. Something like Spring MVC is fairly unobtrusive in your code and allows you existing stuff to run quite a lot as-is. Other frameworks have much more specific ideas about how you should do things.

krosenvold
+2  A: 

Yes it makes sense. However implicit in your question is that the wrong (for you) framework can be more pain than it's worth - and that's true. There is a world of difference between some heavy J2EE framework and something light and cheerful like grails.

frankodwyer
+7  A: 

It makes a lot of sense. My team has spent the better part of five years with our open source stack and no matter and we have a "seed" project (works like appfuse) that we use to create all new web apps. Even the simple two pagers from the pov of maintaining the app, it looks like every other app, just smaller.

The short is you won't get any return on the investment right now, but you will as the project evolves and you maintain it.

tmeisenh
You must have worked on my project too ;)
mugafuga
+2  A: 

What's the alternative? Rolling your own? Embedding all the navigation and logic in the JSPs?

I agree with those who say that a web framework is worth it. There are literally hundreds now (e.g., Struts, JSF, Spring, Wicket, etc.). Pick one that suits you.

duffymo
+2  A: 

There are two kinds of applications:

1) the kind that you throw away and never use again, and therefore should not worry about modularity, maintainability and clarity.

2) the real kind.

It may sometimes seem that your app may never have to grow, scale, or service a larger feature set / user base than you currently are planning for....I assure you, that perception is always wrong.

Frameworks, specifically things like Struts for MVC in Java, Spring for MVC and Dependency Injection, Hibernate for Object-Relational Modeling are all extremely valuable tools that lead to modularity, maintainability and clarity in your code. So, to answer your original question.... Yes, emphatically.

+1  A: 

but my impression of frameworks is that they're mostly used for large J2EE applications and involve a lot of complex configuration

Not necessarily true. The good frameworks are built to scale well so that they will take you from small apps to very large apps. Many of the frameworks today are moving towards zero configuration so you will find them easier and easier to use.

You are right that it does take an initial effort to learn the framework itself but that investment pays for itself in the very first application you build. And meta frameworks like AppFuse makes it even easier to get started since it pre-configures the frameworks for you.

Vincent Ramdhanie
+1  A: 

Frameworks make sense for most applications. It may be necessary for you to build your own or adopt some other framework. The most important questions is the granularity of your data structures. What I mean by this is do you need to just enter data or do you need to parse, compile and execute dynamic code?

If you think of a frame works as a gauge and to the left is an all ready existing frame work open source or closed and to the right is all custom framework then super impose your code on top of that frame work where the level of complexity increases to the right. The farther right you go the more of a stuggle you will have with the frame work (IMO).

However, you can also slowly migrate from existing to custom framework.

There is also the question about your business. If you work for a business that does not look at software as it's core compentency such as a bank or hospital then you need to way that into how much of a frame work you want to build.

Bottom line a framework of some type will always be useful.

+2  A: 

If you don't use a web framework you'll usually end up writing one - poorly.

SamBeran
This is a very good point, and I've seen this done.
MCS
Although on the flip side if you do write one yourself, it's usually exactly what you need - not more and not less.
MCS
+1  A: 

Using a framework may add some overhead to your web-app development due to the learning curve. However, depending on the framework you choose, you may be able to realize the following benefits:

  1. Scalability
  2. Maintainability
  3. Clear Division of your model (e.g. MVC)
  4. Out-of-the-box components(SessionManagement,authentication,etc )
  5. Third party plugins
  6. Modularity inherited from the framework
  7. Many others.

Besides, the learning curve is a variable factor. Some frameworks may be easier to learn than others depending on your skills.

Newbie