Assignment 2 70068027 DP

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

The University of Lahore

Assignment Cover Letter


(Individual Work)

Student Name Mohid-ur-Rehman Program BSSE


Title of
ID 70068027 Assignment 2
Assignment
Section T Due Date 27/March/2021
Submission
Course Name Design Pattern 26/March/2021
Date
Q1. What design issues does both of these patterns address?
ANS:-

• Factory Pattern is an interface for creating objects in a superclass, but allows


subclasses to alter the type of objects that will be created. The factory method model
suggests replacing direct calls to create objects (using the new operator) with calls to a
special factory method.
• Abstract factory pattern lets you produce families of related objects without
specifying their concrete classes. The first thing the Abstract Factory pattern suggests
is to explicitly declare interfaces for each distinct product of the product family example
table, bench etc. Then you can make all variants of products follow those interfaces.
That means all bench variants can implement the bench interface; all table variants can
implement the table interface.
• Both patterns are used when a class doesn't know what sub-classes will be required to
create or when a class wants that its sub-classes specify the objects to be created or
when the system needs to be independent of how its object are created, composed, and
represented or when the family of related objects has to be used together, then this
constraint needs to be enforced.
Basically both pattern almost work same but in abstract factory pattern we make
families of product.
Q2. Draw a UML skeleton diagram for each of the pattern
Ans:-
Q3. Elaborate an example of each design pattern with the help of UML diagrams
ANS:-

You might also like