0% found this document useful (0 votes)
29 views3 pages

Assignment 1 70068027

Uploaded by

Mohid Rehman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Assignment 1 70068027

Uploaded by

Mohid Rehman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

The University of Lahore

Assignment Cover Letter


(Individual Work)

Mohid-ur-
Student Name Program BSSE
Rehman
Title of
ID 70068027 Assignment 1
Assignment
Section T Due Date 11/March/2021
Submission
Course Name Design Pattern 10/March/2021
Date
Question:-
Why are design patterns important? Support your answer with a couple of
examples.
Answer:-
Design Pattern: - Design patterns are the general reusable solution of reoccurring problems in
the application-programming environment.
Programmers often run into the same problem over and over again. Instead of everyone coming
up with his/her own solution to a common problem, we prefer to use a best-practice type solution
that has been already documented and proven to work. We cannot copy paste design pattern in
our code design pattern just represent an idea of problem we should write implementation of that
pattern and then use in our code.

Importance of design patterns: -


Design patterns plays very important role in programmers life they solve most reoccurring
problems they also save time of programmer if programmer stuck in any problem he have to
work a lot to solve the problem on its own but if there’s already same problem exist and its
design pattern available then he don’t need to work just follow the design pattern and solved his
problem

Real life example:- lets we take an example of TEA if someone like tea a lot and he also don’t
know how to make it perfect that’s the main problem for him and it happened with most of the
people. Therefore, some expert person already gave recipe how to make tea perfect. RECIPE
work as a design pattern person just use this designed recipe and solve his problem
Also, we take some example of any other food which recipes already available so if he/she don’t
know how to cook it’s problem for him and recipe work as a design pattern he/she used it and
solved his/her problem.
That is why design patterns are important they help us to solve reoccurring problems correctly
and fast
Question 2:
All kind of patterns can be divided into three kinds:
• Creational
• Structural
• Behavioral
Briefly discuss each kind of the above mention pattern types and establish key differences
among all three.
Answer: -
Creational: - Creational patterns deal with the method of object creation while hiding the
creation logic. Moreover, they are used in situations when the basic form of object creation can
increase design problems or codebase complexity. Instead of instantiating objects directly using
the ‘new’ operator. This gives the program more flexibility in deciding which objects need to be
created for a given use case.
Prototype, builder etc. are creational patterns

Structural: - Structural design patterns deal with class and object composition these design
identifying an easy way to understand how to make connections between class and objects. The
concept of inheritance is used to compose interfaces and define ways to compose objects to
obtain new functionality.
Bridge, decorator etc. are structural patterns.
Behavioral: - These design patterns are specifically concerned with communication between
objects and these patterns explains how objects communicate. It explains how different objects
and classes send messages to each other to make things and how the stages of work are divided
between different objects.
Mediator, observer etc. are behavioral patterns
Whereas, creational patterns are used to describe moment time instant of creation
Structural patterns describe approximately static structures
Behavioral Patterns describe flow or process

------------------------------------------------------------

You might also like