Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Lecture 5- Introduction to Design Pattern (1)

This lecture introduces design patterns as models of code that address common software design problems, emphasizing their language neutrality and essential elements such as pattern name, problems, solutions, and consequences. It discusses the benefits of design patterns, including code reusability, scalability, maintainability, and improved collaboration among developers. The lecture also covers the application of design patterns in the Smalltalk MVC framework and provides guidance on selecting and using design patterns effectively.

Uploaded by

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

Lecture 5- Introduction to Design Pattern (1)

This lecture introduces design patterns as models of code that address common software design problems, emphasizing their language neutrality and essential elements such as pattern name, problems, solutions, and consequences. It discusses the benefits of design patterns, including code reusability, scalability, maintainability, and improved collaboration among developers. The lecture also covers the application of design patterns in the Smalltalk MVC framework and provides guidance on selecting and using design patterns effectively.

Uploaded by

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

Lecture 5

Kazi Rifat Ahmed


Lecturer
Department of Software Engineering
Daffodil International University
Introduction to Design Pattern
● What is Design Pattern
● Design Pattern in Smalltalk MVC
● Describing Design Pattern
● The catalog of Design patterns
Outline ● How Design Patterns solve
Design problems
● How to select a Design Pattern
● How to use a Design Pattern
What is Design
Pattern?
What is Design Patterns?
➔ Design Patterns are models of code that solve classic problems.
➔ They are solutions to software design problems that you can find in
a real-world application.
➔ A Design Pattern is not a code that is ready to be used in your
application, but it is a model that you can use to solve a problem.
➔ Design patterns are language neutral, so they can be applied to any
language that supports object-orientation.
What is Design Patterns?
In general, a pattern has four essential elements:

1. The Pattern name


2. Problems
3. Solutions
4. Consequences
What is Design Patterns?
In general, a pattern has four essential elements:

1. The pattern name is a handle we can use to describe a design problem,


its solutions, and consequences in a word or two. Naming a pattern
immediately increases our design vocabulary.

2. The problem describes when to apply the pattern.It explains the


problem and its context. It might describe specific design problems
such as how to represent algorithms as objects.
What is Design Patterns?
In general, a pattern has four essential elements:

3. The solution describes the elements that make up the design, their
relationships, responsibilities, and collaborations.

4. The consequences are the results and trade-offs of applying the


pattern. Though consequences are often unvoiced when we describe
design decisions, they are critical for evaluating design alternatives and
for understanding the costs and benefits of applying the pattern.
Benefits of Design Pattern
1. Code Reusability: Design patterns encourage the reuse of proven solutions, cut
redundant code and save valuable development time.

2. Scalability: Design patterns provide flexible structures. The structures can adjust to
shifting needs and accommodate future expansions.

3. Maintainability: By utilizing design patterns, code becomes more modular and


easier to maintain.

4. Collaboration: Design patterns establish a widely-used language for developers,


which also fosters effective communication and understanding of the software’s
architecture.
Design Pattern in
Smalltalk MVC
Design Patterns in Smalltalk MVC
➔ The Model View Controller is used to build user interfaces.
➔ Looking at the design patterns inside MVC should help you see what
we mean by the term “Pattern”.
➔ MVC consists of three kinds of an Objects.
➔ Model is the Application Object, the View is its Screen Presentation
and the Controller defines the way the user interface reacts to user
input.
➔ MVC decouples them to increase Flexibility and Reuse.
Design Patterns in Smalltalk MVC
Design Patterns in Smalltalk MVC
➔ The above diagram shows a model and three views.
➔ The model contains same data values, and the views defining a
Spreadsheet, histogram, and Pie Chart display these data in various
ways.
➔ The Model Communicates with its views when its value change, and
the views communicate with the model to access these values.
➔ MVC also lets you change the way a view responds to user input
without changing its Visual Presentation.
Describing Design
Pattern
Describing Design Pattern
Pattern Name and Classification
The pattern's name conveys the essence of the pattern succinctly. A good name is vital,
because it will become part of your design vocabulary.
Intent
A short statement that answers the following questions: What does the design pattern do?
What is its rationale and intent? What particular design issue or problem does it address?
Also Known As
Other well-known names for the pattern, if any.
Motivation
A scenario that illustrates a design problem and how the class and object structures
Applicability
What are the situations in which the design pattern can be applied? What are examples of poor
designs that the pattern can address? How can you recognize these situations?
Describing Design Pattern
Structure
A graphical representation of the classes in the pattern using a notation based on the Object
Modeling Technique.
Participants
The classes and/or objects participating in the design pattern and their responsibilities.
Collaborations
How the participants collaborate to carry out their responsibilities.
Consequences
How does the pattern support its objectives? What are the trade-offs and results of using the pattern?
What aspect of system structure does it let you vary independently?
Implementation
What pitfalls, hints, or techniques should you be aware of when implementing the pattern? Are there
language-specific issues?
Describing Design Pattern
Sample Code
Code fragments that illustrate how you might implement the pattern in C++ or Smalltalk.
Known Uses
Examples of the pattern found in real systems. We include at least two examples from different
domains.
Related Patterns
What design patterns are closely related to this one? What are the important differences? With
which other patterns should this one be used?
The Catalog of Design
Pattern
The Catalog of Design Pattern
How Design Pattern Solve
Design Problems
How Design Pattern Solve Design
Problems
1. Finding Appropriate Objects
2. Determining Object Granularity
3. Specifying ObjectInterfaces
4. Specifying Object Implementations
5. Putting Reuse Mechanisms to Work
6. Delegation
7. Inheritance versus Parameterized Types
How Design Pattern Solve Design
Problems
How to Select a Design
Pattern
How to Select a Design Pattern
1. Consider how design patterns solve design problems.
2. Scan Intent sections.
3. Study how patterns interrelate.
4. Study patterns of like purpose.
5. Examine a cause of redesign.
6. Consider what should be variable in your design.
How to Use a Design Pattern
How to Use a Design Pattern
1. Read the pattern once through for an overview.
2. Go back and study the Structure, Participants, and Collaborations
sections.
3. Look at the Sample Code section to see a concrete example of the
pattern in code.
4. Choose names for pattern participants that are meaningful in the
application context.
5. Define the classes.
6. Define application-specific names for operations in the pattern.
7. Implement the operations to carry out the responsibilities and
collaborations in the pattern.
References
1. https://refactoring.guru/refactoring/smells
2. https://henriquesd.medium.com/design-patterns-introduction-220f811db857
3. Reference Books
Thank You

You might also like