Hey guys,
Do we really need a framework for java web application ? Isn't it an over kill for most of projects ? Some simple filters and servevice Facades do the trick! and view will be rendered by the JSPs , what do you think ?
Before we dive into the frameworks, I want to back to basics to give some context behind why the frameworks exist and what benefits they provide. let's look at a naive model 1
Model 1 web application architecture is where all of your logic is wrapped up inside the pages of your application. By logic, I'm referring to things like business logic, presentation logic and page flow.
The Model 2 architecture overcomes many of the problems of the Model 1 architecture. Model 2 is based upon the Model-View-Controller (MVC) architecture. In a Model 1 web application, the pages are accessed directly, in a Model 2 architecture all access is routed through a controller component (typically implemented by a servlet).
We can use the same controller for the entire site, or multiple controllers that are each responsible for sections of the site. For both, the principle of the design is the same: requests from clients are routed to a central controller, which decides how the request should be serviced. When it processes the request, the controller may make some modifications to the underlying model (often JavaBeans). Once the request has been serviced, the controller delegates the task of sending back the response to a view component (often implemented by JSP pages). The view component generally contains a minimal amount of code and is focused on the task of presenting information to the end user. Both the controller and the view components can access and modify model components.
Benefits of Model 2 Architecture
So how does using Model 2 architecture improve the design of our web application over using Model 1?
Enhancing Maintainability
As the controller component in our architecture is responsible for determining which page in our web application we should see next, the structure of the web application is defined in a single place. This increases the maintainability of the application, particularly if we go further, separating out the structural definition from the controller to make the structure externally configurable. Additionally, the processing and business logic associated with servicing requests is easy to find as it is not embedded and scattered throughout the pages of the system (unlike in the Model 1 architecture).
Promoting Extensibility
The logic that processes each type of request in Model 2 is now much more centralized. This centralization, in conjunction with splitting the view components from the logic that services the request, means that the system is now much easier to extend than in Model 1 architecture. By introducing more componentization we make extensions easier to write and the chances of a ripple effect throughout the application much less likely. For example, to extend the application by adding new pages, all that we need to do is add new view components and make appropriate modifications to the controller component – either directly or through external configuration files.
Ensuring Security
When we discussed the security aspects of Model 1 earlier, we noted that routing all requests through a single point of entry is a simple way to handle web application security. In Model 2, we can use this technique, because all security processing can be moved to the controller(s), reducing the burden on developers and the risk of accidental security breaches.
Now Why Framework…..The common using Struts framework is a good MVC (model2) framework which gained considerable attention over the course of the last year because of its ease of use and ability to fit today's developers' needs in building applications and building them fast. Struts combines Java servlets, Java Server Pages (JSP), custom tags, and message resources into a unified framework and saves the developer the time of coding an entire MVC model, a considerable task indeed.
Laseelan PM
Model 2 Rules, The controller functionality is gr8 !.
But a Servlet 2.4 container already provides a controller ! Why do you need just another one ? Wether we use a framework or not we need a well designed mode and service layer. In order to tie these together, we can use servlet filters and JSPs, that too declaratively.
Now what do the frameworkds do apart from that ?
Extendability ? container provides that
modularity ? container provides that
Maintainability ? What is more mainintanable than plain java classes and JSPs ?
The point I'm trying to make is that, we already have a declarative controler in the container. it's flexible, pwoer full and proven. That has been used for last 10 years !
Now we have made enough experiments on the frameworks. None of then can provides more functionalities than container +filters +model+service with a few libraries ( for example pulolating beans and all.
--Sarath PS
absolutely I agree with that there is no need for a framework for java application. Servlet JSP and some some filters in MVC architecture is enough I think.
If you can build your own framework using Servlets + Filter then its good.
but you need to follow the below points.
1: An application design must have a strategy for serving current and future client types.
2: A Web-tier controller must be maintainable and extensible. Its tasks include mapping requests to application model operations, selecting and assembling views, and managing screen flow. Good structure can minimize code complexity.
3: Application model API design and technology selection have important implications for an application's complexity, scalability, and software quality.
4: Choosing an appropriate technology for generating dynamic content improves development and maintenance efficiency.
The common external MVC frameworks are Struts and Spring, they are not forcing us to use there patters as they wrote, They are also providing some extensions to customize that to our needs.
If you can build your own framework using Servlets + Filter then its good.
I believe building your own framework is re-inventing the wheel !. What I mean is servlet spec, it self is providing a good framework for application integration.
1: An application design must have a strategy for serving current and future client types.
The servlets provides the same, again using filters, Sitemesh is a good example of this. It supports different
client types. Or you can use a seperate servlet for rendering the veiw. This is what exactly the frameworks are doing.
2: A Web-tier controller must be maintainable and extensible. Its tasks include mapping
requests to application model operations, selecting and assembling views, and managing screen
flow. Good structure can minimize code complexity.
The web container itself is a first class controller, that can be configured through web.xml. You can map your request by checkking the URLs, It also supports seperation of concerns. Why do you need to worry about the authorisation code, when you just want to insert some data to the database ? Define a URL according to access levels, and configure a filter so that, it 'll be invoked by the container. Note that you don't need to do any coding for this, you can re-use an already existing one.
3: Application model API design and technology selection have important implications for an
application's complexity, scalability, and software quality.
I'm not talking about application design, it's about the framework. :) You don't want to change your model to adapt the framework I believe !
--Sarath PS
>>1: An application design must have a strategy for serving current and future client types.
Yes even if it is a framework
>>2: A Web-tier controller must be maintainable and extensible. Its tasks include mapping requests to application model operations, selecting and assembling views, and managing screen flow. Good structure can minimize code complexity.
Yes ofcourse Good design allways... But if you are designing for a "product", then it is always better to design your self. I allways belive that our own application model design is good.
>>3: Application model API design and technology selection have important implications for an application's complexity, scalability, and software quality.
YES but I dont think this is a plus point of a common framework
>>4: Choosing an appropriate technology for generating dynamic content improves development and maintenance efficiency.
Yes it is also not a big issue
>>The common external MVC frameworks are Struts and Spring, they are not forcing us to use there patters as they wrote, They are also providing some extensions to customize that to our needs.
If you are going to customise these frameworks then the advantage of using the frame work will reduce.
I said that we can have an option to do some additional task with the help of the existing Framework, it doest mean restructuring
Its is sure that the framework need some extra functionality for there services,
Compare to Servler+Filter+JSP its response time is not good.
But if the resource strength become big then, To my opinion need to go for a good stable framework, so that the maintance will be much easy than traditional Servlet+Filter+JSp app
I believe building your own framework is re-inventing the wheel !. What I mean is servlet spec, it self is providing a good framework for application integration.
All the External frame works are top of exsisting Servlet framework, what i mean that creating is framework is not re-inventing the wheel !. we are just abstracting the http request and responce cycle through our framework, the rest is done buy our exsiting Servlet framework
Before we dive into the
model 2 Rules!
absolutely I agree with that
If you can build your own
the framework war, or no war at all
>>1: An application design
I said that we can have an
I dont think maintenance
I believe building your own
Yes.. Then why you need a