Design patterns are standard way of solving problems, used during the design of the system. It is a general recurrent solution to a common occurring problem in software design.
Two categories of design patterns:
1. Normal programming design patterns
2. Enterprise design patterns
3 Kinds of J2EE design patterns
1. Creational -> for creating Object
2. Structural -> for relating objects
3. Behavioural -> dealing with interaction and responsibility of objects
Creational Design Patterns -
1) Singleton -> Ensures only one object is create for the entire application
public class Single{
private static Single instance =new Single();
private Single() {};
public static Single getInstance(){
return instance;
}
}
Notes: When constructor is private, one cannot instantiate that class from outside.
2) Factory ->
eg: Sax Parser, Dom parser
replica of an object - using clone()
Behavioural Design Patterns -
DAO - Design pattern in which single class interacts with database
DTO - Pattern used to send multiple attributes to server in single go
MVC- Model View Controller. Model(DB, Programming logic, Business logic) handles data, view(jsp/html) for display, and controller(web.xml) to control the application.
DAO design pattern
Main purpose is to isolate/encapsulate DB code to one specific class. This helps in object reuse. Other applications can make use of helper class. It is one self contained area where db code is located.
It is common pattern, best practise,
Architectural Design Patterns:
Challenge: The graphical user interface enables the user to communicate with a computer application. The graphical user interface is not supposed to make decisions, validation, data storage, database connection, and other tasks.
Solution: MVC Design pattern:
MVC Design Pattern - Architectural design pattern for separating the interaction of user and the web application in to 3 main concerns.
ViewTwo categories of design patterns:
1. Normal programming design patterns
2. Enterprise design patterns
3 Kinds of J2EE design patterns
1. Creational -> for creating Object
2. Structural -> for relating objects
3. Behavioural -> dealing with interaction and responsibility of objects
Creational Design Patterns -
1) Singleton -> Ensures only one object is create for the entire application
public class Single{
private static Single instance =new Single();
private Single() {};
public static Single getInstance(){
return instance;
}
}
Notes: When constructor is private, one cannot instantiate that class from outside.
2) Factory ->
eg: Sax Parser, Dom parser
replica of an object - using clone()
Behavioural Design Patterns -
DAO - Design pattern in which single class interacts with database
DTO - Pattern used to send multiple attributes to server in single go
MVC- Model View Controller. Model(DB, Programming logic, Business logic) handles data, view(jsp/html) for display, and controller(web.xml) to control the application.
DAO design pattern
Main purpose is to isolate/encapsulate DB code to one specific class. This helps in object reuse. Other applications can make use of helper class. It is one self contained area where db code is located.
It is common pattern, best practise,
Architectural Design Patterns:
Challenge: The graphical user interface enables the user to communicate with a computer application. The graphical user interface is not supposed to make decisions, validation, data storage, database connection, and other tasks.
Solution: MVC Design pattern:
MVC Design Pattern - Architectural design pattern for separating the interaction of user and the web application in to 3 main concerns.
- Isolates business logic from user interface
- Makes it easier to manage complexity of application through the separation of concerns
- Other benefits
- developer specialization, focus and parallel development by separate teams.
- Heart of web application.
- Represents the information(the data) of the application and the business rules used to manipulate the data
- Retrieve data and convert(process, validate) to meaningful concepts.
- At a first glance, it can be looked as the first layer of interaction with any database you might be using for your application.
- Ejbs, Dao objects, or service objects may be the model
- View corresponds to elements of user interface - It is just a set of webpages
- It is like a mediator between Model and View
- Manages the details involving the communication between Model and View
- Handles user actions to the Model or View as required
- Controls the data flow into Model object and updates View whenever data changes. It keeps View and Model Separated










No comments:
Post a Comment