MVC2 Architecture in Struts – Struts Tutorial

MVC2 Architecture:-

  • In MVC2 architecture multiple layers will be there representing multiple logics. These multiple logics will be developed by taking the support of multiple technologies.
  • A layer is a logical patrician in the application representing logics.
  • Architecture speaks about arrangement of layers, communication b/w layers towards application development.

Advantages of MVC2:-

  1. Clean separation of logics is possible.
  2. Modification done in logics of one layer does not effect the logics of another layer.
  3. Gives easiness to maintain & enhance the projects.
  4. Parallel development is possible so productivity is good.

How parallel development is possible:-

The project leader divides team into 2 parts

1)      Web authors

2)      JEE developers

  • Web authors use servlet, jsp technology and develops view layer, controller layer logics.
  • JEE developers takes the support of EIB, spring, hibernate, java bean &etc….technologies and develops model layer logics.
  • Since these two part work parallely we can say parallel development is possible.
  • Certain model layer technologies like EJB, spring use built in middle wire services. This reduces burden on the program.

Disadvantages of MVC2 Architecture:-

  • Knowledge on multiple technologies is required.
  • For parallel development multiple programmers are required.
  • While developing MVC2 architecture based web applications we must follow certain rules along with working with multiple technologies having multiple layers .these rules are

1)      Every layer is given to maintain certain logics so place only those logics are suggested to place and do not place any excess logics.

2)      All operations in web application execution must take place under the control of controller servlet.

3)      They can be multiple businesses components in model layer and multiple jsp programs in view layer but their must be only one servlet program in controller layer.

4)      View layer resources & model layer resources must not interact with each other directly they must interact with each other controller servelet.

5)      Two resources of view layer should not interact with each other (jsp programs) directly their most communicate with each other through controller servlet.

Question: The MVC architecture is designed to use certain technologies in each layer can you tell me reasons behind those suggestions?

Question: Can I change the roles of these technologies?

Answer: – Yes, we can change the roles but it is not recommended to do that work.

Reasons:-

If servlet is taken in view layer:-presentation logic of website changes at regular intervals when presentation of logic of servlet is modified programmer need tore-compile the srvlet program &needs to reload the web application.

  • Whereas logics in jsp program can be modified without those recompilation & reloading operations. So jsp are recommended in view layer.

If jsp program is taken as controller:-

To improve readability of jsp the jsp program must be developed as java codeless jsp program (write only tags) but as controller it will be forced to have java code representing integration logic. Bc3 tags are not their to communicate with EJB spring applications of model layer. So take support of servlet program as controller where java code can be added properly without any restrictions for integration logic.

If EJB component/Hibernate app/ spring app is taken as view layer/ controller layer resource…

The above thought itself wrong bc3 view layer, controller layer resources must handle http protocol based request, response but the above applications cannot do that work. So it is recommended to take servlet, jsp programs who can handle http protocol based req. res in controller, view layer.

 If separate servlet program/jsp program is taken in model layer as business component:-

  • The business logic placed in servlet/jsp program.

a)      Specific to current web application(not reusable)

b)      Allows only http request based clients.

c)       Force the programmer to develop some middleware services manually

  • To overcome these problems use EJB component, spring app, spring with hibernate app to develop model layer logics.
  • Design pattern is set of rules which come as best solution for re-occurring problems of application development.
  • Design pattern are given to develop s/w applications by using software technologies much effectively.
  • Design patterns are best practices that are noticed by senior developer to solve problems in application development.
  • Programmer should implement design pattern in coding phase of project development.

Example: – singleton java class, factory method, dao, MVC2 and etc

  • The worst solution for re occurring problem is called as “anti pattern”
  • Initially MVC2 pattern is design pattern to solve the problems of regular web application development. Later it as become architecture based on its popularity of developing web application & creating new s/w technologies like struts, JSF and etc.

Leave a Reply

Your email address will not be published. Required fields are marked *