Composite Entity pattern is used in EJB persistence mechanism :
Following are the participants in Composite Entity Bean:
The intercepting filter design pattern is used when we want to do some pre-processing / postprocessing with request or response of the application:
Business Delegate Pattern is used to decouple presentation tier and business tier:
It is basically use to reduce communication or remote lookup functionality to business tier code in presentation tier code.
In business tier we have following entities:
Following are the entities of this type of design pattern:
Following are the differences between a static class and a singleton class:
There are multiple ways to write thread-safe singleton in Java e.g by writing singleton using double checked locking, by using static Singleton instance initialized during class loading. By the way using Java enum to create thread-safe singleton is most simple way.
It is two step process:
Data Access Object Pattern or DAO pattern is used to separate low level data accessing API or operations from high level business services.
Following are the participants in Data Access Object Pattern:
Observer pattern is based upon notification, there are two kinds of object Subject and Observer.Whenever there is change on subject's state observer will receive notification.
Creational patterns use inheritance to decide the object to be instantiated.
MVC Pattern stands for Model-View-Controller Pattern. This pattern is used to separate application's concerns.
The service locator design pattern is used when we want to locate various services using JNDI lookup:
In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book titled Design Patterns - Elements of Reusable Object-Oriented Software which initiated the concept of Design Pattern in Software development.
These authors are collectively known as Gang of Four GOF.
An example of Adapter pattern:
Throw exception within the body of clone method.
Following are the entities of this type of design pattern:
The front controller design pattern is used to provide a centralized request handling mechanism so that all requests will be handled by a single handler.
This handler can do the authentication/ authorization/ logging or tracking of request and then pass the requests to corresponding handlers.
Following are the entities of this type of design pattern:
Factory pattern used to create object by providing static factory methods. There are many advantage of providing factory methods e.g. caching immutable objects, easy to introduce new objects etc.
Design patterns can be classified in three categories:
Creational Patterns - These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new opreator. This gives program more flexibility in deciding which objects need to be created for a given use case.
Structural Patterns - These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
Behavioral Patterns - These design patterns are specifically concerned with communication between objects.
Singleton pattern in Java is a pattern which allows only one instance of Singleton class available in whole application.
Following are some of the design patterns which are used in JDK library:
Factory pattern encapsulates the implementation details and underlying implementation can be changed without any impact on caller api.