Wednesday, February 6, 2013

Selecting the JVM framework

For various reason all the time we are confused to choose the perfect framework for various reason. Some times for benefits of application development and most of the time for the purpose of career. Recently from a web search, I havea pdf consisting some information regarding this issue. Here is the snapshot of that note.

Some factors for choosing frame work:
  • Request, Component or RIA Framework
  • Ease of Development
  • Project Community
  • Project Future and Roadmap
  • Maintenance
  • Technical Features
Types of application we need to develop:
  • High-traffic, internet facing, infinite scalability
  • Intranet-based, behind the firewall, few users
  • Products, to be maintained for 5-10 years
  • Legacy Backend
  • Others?
Actually the framework should be choose depending on the requirements in project:



»Request Based Frameworks -----------Struts 2, Spring MVC, Rails, Stripes

»Component Based Frameworks.-----------JSF, Tapestry, GWT

»Rich Internet Applications -------------Flex

»One Size Fits All -------------Grails

Generically we may map framework depending on project as:

»High-traffic, internet facing, infinite scalability:
       -------- Request-based frameworks
»Intranet-based, behind the firewall, few users:
       --------Component-based frameworks
»Products, to be maintained for 5-10 years:
       --------Largest Community, Most Vendor Support
»Legacy Backend:
       --------- Same Language as backend

At this time many points should be checked before choosing framework:
1. Developer Productivity
2. Developer Perception
3. Learning Curve
4. Project Health
5. Developer Availability
6. Job Trends

7. Templating
8. Components
9. Ajax
10.Plugins or Add-Ons
11. Scalability
12.Testing Support

13.i18n and l10n
14.Validation
15. Multi-language Support (Groovy / Scala)
16.Quality of Documentation/Tutorials
17.Books Published
18.REST Support (client and server)
19.Mobile / iPhone Support
20.Degree of Risk

The following matrix shows the ratings:


Matrix Result:


  • Spring MVC (17)
  • GWT (17)
  • Ruby on Rails (17)
  • Grails (16.5)
  • Wicket (14.5)
  • Struts 2 (14.5)
--------------------------
Spring MVC
-------------------------
Pros
  • – Easy Configuration with Annotations and Conventions
  • – Integrates with many view options seamlessly: JSP/JSTL, Tiles, FreeMarker, Excel, PDF, JSON
  • Excellent REST Support
Cons
  • – Instant reload not built-in, need JRebel or Spring Roo
  • – No open development process, need to be SpringSource
  • – Ajax requires 3rd-party library (can be a good thing!)

--------------------------
GWT
--------------------------
Pros
  • Write Java => Produces Optimized JavaScript
  • Easy to learn and develop with standard Java Tools
  • Vibrant Community
Cons
  • You have to know Java
  • Slow to compile, difficult to test
  • More like a JSP Tag Library than a web framework

-----------------------
Ruby On Rails
----------------------
Pros
  • Easy to learn and understand for Web Developers
  • Lots and lots of documentation
  • Passionate Community
Cons
  • Slightly less performant by default
  • Dynamic language means more tests
  • Development Tools and Debugging

---------------------
Grails
--------------------
Pros
  • Easy dynamic language transition for Java Developers
  • Groovy
  • Plugins for all types of applications
Cons
  • Groovy learning targets Java Developers
  • Stack traces are horrendous
  • Knowledge of underlying frameworks not required, but helpful
---------------------
Wicket
---------------------
Pros
  • Great for Java Developers
  • Tight binding between pages and views
  • Active community - support from creators
Cons
  • No Jobs or Developers
  • Stateful by default
  • HTML Templates live next to Java code by default





Monday, February 4, 2013

MVC in Sturts 2 and the flow of execution.

At first check  MVC funda

Suppose we want to create a application to show greetings for an interaction in by user. For this purpose, we can provide a page for initial interaction by the user. Suppose this page is index.jsp. This page contains a link by clicking which the user is able to get greetings from application. to so so we need to make following arrangements:


  1. Create a class to store the welcome message (the model)
  2. Create a server page to present the message (the view)
  3. Create an Action class to control the interaction between the user, the model, and the view (the controller)
  4. Create a mapping (struts.xml) to couple the Action class and view




How the code works here:
A browser sends to the web server a request for the URL 


  1. User send request by clicking on the link and in the link it is depicted which action will be implemented.
  2. The container receives from the web server a request for the depicted resource grettings.action. According to the settings loaded from the web.xml, the container finds that all requests are being routed to org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter, including the *.action requests. The StrutsPrepareAndExecuteFilter is the entry point into the framework.
  3. The framework looks for an action mapping named (i.e)"greetings", and it finds that this mapping corresponds to the class . The framework instantiates the Action and calls the Action's required method.
  4. The method creates the GreetingProvider (model) object and returns SUCCESS(feedback strings). The framework checks the action mapping to see what page to load if SUCCESS is returned. The framework tells the container to render as the response to the request, the resource welcome.jsp.
  5. As the page welcome.jsp is being processed, and the tag merges into the response the value of the required attributes.
  6. A pure HTML response is sent back to the browser.




Friday, February 1, 2013

MVC- Model View Controller

All the time we hear about it and the term itself made an image in mind. But still there is some fog in it. Recently i have got three definition regarding this three layers, and after that i am able to remove the fog about it:

MVC means Model-View-Controller where model is responsible for business logic, view handles the user interaction with application and controller decides the flow of application.
  • Model – A class which supplies the data needed for the application. 
  • View – A view element which displays the data.It displays the message returned by the Model class.
  • Controller – A controller class which will respond to user URL request. The controller will coordinate the actions of Model and the View. 


1) User sends the request using view which reaches to the controller on the server.
2) Controller decides the respective model and delivers the control to particular model.
3) As a result of business processing, model changes its state.
4) Depending on the state change of model, control redirects the flow to the view.
Main advantage of this architecture is the separation of data layer, presentation layer and pure business logic.