Docsity

Understanding the MVC Design Pattern in J2EE Applications, Slides of Design Patterns

Partial preview of the text

Download Understanding the MVC Design Pattern in J2EE Applications and more Slides Design Patterns in PDF only on Docsity!

Overview of Design Patterns

The MVC Design Pattern

Sapana Mehta

Design Patterns

  • (^) A pattern is a proven solution to a problem in a context.
  • (^) Christopher Alexander says each pattern is a three- part rule which expresses a relation between a certain context, a problem, and a solution.
  • (^) Design patterns represent a solutions to problems that arise when developing software within a particular context. i.e Patterns = problems.solution pairs in a context

Categorizing Pattern

Patterns, then, represent expert solutions to recurring problems in a context and thus have been captured at many levels of abstraction and in numerous domains. Numerous categories are:

  • (^) Design
  • (^) Architectural
  • (^) Analysis
  • (^) Creational
  • (^) Structural
  • (^) Behavioral

Sun’s J2EE Framework

  • (^) Components Containers and Connectors:

Hiding Complexity, Enhancing Portability

  • (^) Components are the key focus of application

developers

  • (^) Containers intercede between clients and

components, providing services transparently

to both, including transaction support and

resource pooling.

  • (^) Connectors sit beneath the J2EE platform,

defining a portable service API to plug into

existing enterprise vendor offerings.

J2EE and Design Patterns

• J2EE: AN OPERATING SYSTEM FOR THE WEB

Enterprise web applications, which live on networks and are accessible through browsers, are redefining Enterprise Web Software. This is the next wave of computing.

  • (^) The J2EE architecture is built to enable

component developers to use a Model View

Controller (MVC) Design Pattern.

MVC continued

  • (^) Solution (how do you solve the problem)
    • (^) Use the software engineering principle of “separation of concerns” to divide the application into three areas: - (^) Model encapsulates the core data and functionality - (^) View encapsulates the presentation of the data there can be many views of the common data - (^) Controller accepts input from the user and makes request from the model for the data to produce a new view.

MVC Structure for J2EE

Example of MVC Design Pattern

  • (^) Let’s investigate this statement by looking at

a small application that demonstrates MVC on

J2EE

Java Pet Store- MVC Design Pattern  (^) The Java Pet Store is a reference application that demonstrates J2EE technologies.  (^) It demonstrates interaction between Java Server Pages (JSP's), custom Tag Libraries, JavaBeans, and Enterprise Java Beans.  (^) It demonstrates a real-world approach to application development, where the presentation of data is separated from the process of obtaining data from objects which interact with the enterprise or database tier.  (^) The Pet Store application implements MVC (Model- View-Controller) design, and demonstrates one way to design an application that should scale well.

J2EE Architecture Tiers

A. Details of Client Tier

  • (^) The Client tier is responsible for presenting data to the user, interacting with the user, and communicating with the other tiers of the application.
  • (^) The Client tier is the only part the application the user ever sees.
  • (^) The Client tier communicates with other tiers by way of well-defined interfaces.
  • (^) A separate Client tier in the design provides flexibility and extensibility.

B. Web Tier

  • (^) The Web tier is responsible for performing all Web- related processing, such as serving HTML, instantiating Web page templates, and formatting JSP pages for display by browsers.
  • (^) The Web tier in the Java Pet Store does all of these, and takes on the Controller functions for the Web application, caching model data interpreting user inputs, selecting appropriate Views based on application flow, and managing database connections.

C. EJB Tier

  • (^) Enterprise JavaBeans are software business components which extend servers to perform application-specific functionality.
  • (^) The interface between these components and their containers is defined in the EJBs specification.
  • (^) Essentially, the EJBs tier provides a component model for access to distributed system services and persistent data.