1. creational pattern 2. structural Pattern 3. Behavioral Pattern
1. Creational Pattern
It have some types. They are Abstract factory, Singleton Factory ,prototype pattern etc..
a. singleton factory:- No more than one instance . It provides a single global point of access to that instance.
For Example coding: (Database Connection)
public class DatabaseConnectionFactory {
private static DatabaseConnectionFactory DBfactory = new DatabaseConnectionFactory();
public static DatabaseConnectionFactory getInstance() {
return DBfactory;
}
private DatabaseConnectionFactory() {
}
public Connection getDBConnection() {
DatabaseConnect dbase = new DatabaseConnect();
return dbase.getConnection();
}
}
b. Abstract factory:- Provides an interface to create and return one of several families of related objects.
c. Prototype Pattern :- Initialized and instantiated class and copies or clone it to new instances rather than creating new instances.
No comments:
Post a Comment