Professional Documents
Culture Documents
“Note
Attempt all questions.
Do not copy and paste. Write in your own words
Marks should be evaluated based on plagiarism’s report and quality.
1. Compare and contrast between following Design Patterns. Draw a table for
comparison. (10)
Deal with one Only instance of class Deal with new objects by copying
at any time. or cloning existing object
Create the instance of class on No demand, but shallow and deep
demand cloning occur
Base on Lazy initialization concept Base on Expensive initialization
Prototype is single because it does not But in the side of Singleton class is
essential class but only object needed.
Provide and interface for creating Deal with creating step by step of
object of related families. object and return final object.
No specify the Concrete Classes It implies only one type of creating
object
It deals with simple creating of object It deals with complex creating of
object
Abstract Factory concern to return the Builder Return the product as final
product as soon as possible product or final step.
Invariant:
1. Context product inv quantityOverZero: Self.Quantity>0
Pre-Condition:
1. Context personCreator::CreatePerson(newPerson) pre: Person.name=>forAll(x|
x.name!=Person.name)
Post-Condition:
1. Context cancelOrder::cancel(newPrice,newQuantity) post:
Item.quantity=newQuantity,
Item.price=newPrice
Record the behavior or activities more than one screen. Like behavior
concern with communication between objects.
ii. Ans. This case study deal with creational Design Pattern. Because according to
scenario there is user choice and it may apply factory method which is creational
design pattern. Following reason:
Creational deal with way of creating object
When decision made at time creational pattern use.
Allow user to pick categories
Portfolio depend on user choice
These all reason tells that this is creational design pattern.
c. “For this question you can use your knowledge about design patterns and for
given situation recommend a solution. State the name of pattern(s) that can solve
this situation, how this pattern(s) is used to solve. You do not need to provide
pattern details”
i. Ans. This case deal with the Factory Design Pattern due to some following
reason:
Factory lets the subclass to create which type of object. Here all depend to
user choice.
It deals with simple creating of object, when user choose any operation like
“Train or bus” abstract class create object and return.
Factory concern to return the product as soon as possible (in case of “bus
Train or Flight Travel”).
ii. Ans. This case deal with the Builder Design Pattern due to some following
reason:
Builder create step by step object and return the final object (in this case
build” wall, roof , basement” and give final result as building.)
Builder Design Pattern concern to return Final Produce (in case of this
“Building is final Product”).