Design Pattern
Design Pattern
Creational
Creational Patterns are used to resolve Object Creation Requirement
Structural
These patterns are used to define a class's structure. The aim of these patterns is to
increase/modify the class functionality, without changing more code.
Behavioral
Behavioral patterns are used to achieve runtime requirement (like define how one class
communicates with others)
Interface
(Product)
Concreate Creator
Required Object
From Factory
Interface X Interface Y
Abstract Factory
Z
Interface X
Interface Y
Advantages
We will get performance benefit, while creating duplicate
complex object
Desktop /
Processor Memory
Laptop
Additional Storage
Checkout
Devices
Obj.ShowDetails();
Obj.ShowDetails();
Director
{
IBuilder CreateProduct (IBuilder B, string
Parm)
CreateProduct() {
Initialize(); B.CreateProduct()
ReturnProduct(); B.Initialize();
B.ReturnProduct();
}
}
DesktopBuilder :
IBuilder
{
//Create Laptop Object
// Build laptop Object
// Return Laptop Object
}
Director
{
IProduct IBuilder CreateProduct (IBuilder B, string
Parm)
SetProcessor CreateProduct() {
SetMemory Initialize(); B.CreateProduct()
SetStorage ReturnProduct(); B.Initialize();
SetMonitor
B.ReturnProduct();
}
}
Director
Iproduct IBuilder
Product Director
Builder Product
Desktop : Iproduct
DesktopBuilder :
Concreate Ibuilder
Product
Builder Concreate
Product
Advantage
Customer
Application A GetReorts()
Customer
Application B GetReorts()
iEntity Obj= new Customer();
Obj.GetPdfReport();
iEntity
iEntity Obj= new
GetReorts()
Employee();
Obj.GetPdfReport();
Employee
GetReorts()
Customer
GetReorts()
Application B
iReport
iReport Obj= new CustReport(); iEntity
Obj.GetPdfReport(); GetPdfReport
GetHTMLReport GetReorts()
iReport Obj= new EmpReport();
Obj. GetPdfReport();
GetXMLReport
Employee
GetReorts()
CustReport Customer
Application
Customer
iEntity Obj= new Customer();
Obj.GetReport();
Employee
Cust_Report
Customer
ReportHeader()
Customer.GetReport GetReports()
()
iEntity Obj= new ReportFooter()
Cust_Report();
Obj.GetReport(); iEntity
iEntity Obj= new GetReports()
Emp_Report();
Obj.GetReport();
Emp_Report
Employee
ReportHeader()
GetReports()
Employee.GetReport(
)
ReportFooter()
Sensitivity: Internal & Restricted
Adapter Pattern
Convert one class in to another class
Decorator Pattern
Include additional functionality for same class
SubSystem 1
Client Application
Façade Class
SubSystem 2
FaçadeClass.Do() SubSystem1.do()
SubSystem2.do()
SubSystem3.do()
SubSystem 3
Gateway
ProcessPayment()
Client Application
Façade Class Inventory
Façade.PurchaseTicket( Gateway.ProcessPayment(
) ) UpdateInventory()
Inventory.UpdateInventory
()
Notification.SendTicket()
Notification
SendTicket()
Advantages
Client Application
Proxy Class MainClass
ProxyClass.Do() Authentication.do Network /
() Local Do()
ValidRequest.do()
Proxy.do()