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

DESIGN PATTREN

Assignment no: 1

Submitted by:
M Waqas Arif
70067876
Section T

Submitted to:
Resp. sir Zunair sb

MARCH 10, 2021


UNIVERSITY OF LAHORE
Q1: Why are design patterns important? Support your answer with a couple of
examples.

Importance:
Design pattern describe problems that occur over and over again in software development
and provides the best solution for the reoccurring problems. Design patterns play a
significant role in coding environment, all of the big software like Facebook, Microsoft
office …etc. uses some kind of design pattern, these are the giants in software industry, if
software like these are built using design patterns shows us how important are design
pattern. Some of the advantages of using design pattern are:

• It makes software flexible


• It saves human effort
• It increases the code reuse-ability
• It makes software less coupled and highly cohesive
• It makes programming code efficient
• Speed up the development process
• It saves a lot of time
• Helps to prevent issues that can cause major problems
There are some consequences of applying a design pattern some pattern may include some
conditions to be applicable but they provide more advantages than disadvantages.

Examples:

➢ Inheritance
Inheritance is a well know example of design pattern, it is a technique
that is used in object-oriented programming to develop a software system, inheritance is a
design pattern that was design to make programming code re-useable and to save time and
human effort and to make the programming code more efficient.

➢ Encapsulation
While developing a software there is some sensitive information that
software developers thought should be hidden from the user or client, so a design pattern
was introduced very well-known pattern today as Encapsulation that is used by so many
developers today to hide data.
This design pattern solves the problem of data hiding and provides benefits to the
developer as well as the client.
Q2: All kind of patterns can be divided into three kinds:
1. Creational
2. Structural
3. Behavioral
Briefly discuss each kind of the above mention pattern types and establish key
differences among all three.

1. Creational
These creational patterns are design to deal with the object at the time of its
creation, in simple words these patterns create objects in a way that is suitable according
to the situation. Normally when we create object that can make the system complex or can
cause problem at the time of its creation. The creational design pattern deal with these kinds
of object creation problems.

2. Structural
Structural patterns define how each component or entity should be constructed
so as to have very flexible interconnecting modules which can work together in a larger
system. Structural design pattern also describe how data moves through pattern.

3. Behavioral
Behavioral patterns define how the communication between objects can
be done without making the system highly coupled.

o Differences

Creational (pattern) Structural (pattern) Behavioral (pattern)

1. This design pattern deals 1. By using this pattern, we can 1. This pattern describes the
with the object at the time connect the modules to work communication between
of its creation. together in a flexible way. objects
2. Creational pattern stops 2. This pattern also describe how data 2. It makes the system loosely
the complexity that can move through pattern coupled
occur at the time of object 3. Interpreter Pattern and
creation. 3. Adapter pattern and Bridge pattern
Iterator Pattern are the
3. Abstract factor pattern and are the example of this pattern
Builder pattern are the examples of this pattern
example of this pattern.

You might also like