0% found this document useful (0 votes)
3 views

Design Patterns 2

The document is a course outline for Software Re-Engineering (SE473) at the International Islamic University, covering topics such as Object-Oriented concepts, Design Patterns, their classifications, and popular examples. It discusses the importance of design patterns in achieving good design objectives like readability, maintainability, and reusability, while also addressing their pros and cons. The document concludes with a brief mention of specific design patterns like Strategy and Singleton, along with their advantages and disadvantages.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Design Patterns 2

The document is a course outline for Software Re-Engineering (SE473) at the International Islamic University, covering topics such as Object-Oriented concepts, Design Patterns, their classifications, and popular examples. It discusses the importance of design patterns in achieving good design objectives like readability, maintainability, and reusability, while also addressing their pros and cons. The document concludes with a brief mention of specific design patterns like Strategy and Singleton, along with their advantages and disadvantages.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

02/08/

25

1
Software Re-Engineering
Course Code: SE473

Department of Software Engineering,


Faculty of Computing,
International Islamic University, Islamabad.

02/08/
25

2
Contents
• Introduction to OO concepts
• Introduction to Design Patterns
• What are Design Patterns?
• Why use Design Patterns?
• Elements of a Design Pattern
• Design Patterns Classification
• Pros/Cons of Design Patterns
• Popular Design Patterns
• Conclusion
3
• References
Why use Design Patterns?
• Design Objectives
• Good Design (the “ilities”)
• High readability and maintainability
• High extensibility
• High scalability
• High testability
• High reusability

4
Why use Design Patterns?

5
Elements of a Design Pattern
• A pattern has four essential elements (GoF)
• Name
• Describes the pattern
• Adds to common terminology for facilitating communication (i.e. not
just sentence enhancers)
• Problem
• Describes when to apply the pattern
• Answers - What is the pattern trying to solve?

6
Elements of a Design Pattern (cont.)
• Solution
• Describes elements, relationships, responsibilities, and collaborations
which make up the design
• Consequences
• Results of applying the pattern
• Benefits and Costs
• Subjective depending on concrete scenarios

7
Design Patterns Classification
A Pattern can be classified as
Creational
• Creational patterns deals with object creation. Class scope creational
patterns defer some part of the object creation process to subclasses.
Object scope creational patterns defer it to another object.
Structural
• Structural patterns deals with compositions of objects and classes.
Structural class patterns are based on inheritance to build a structure.
Structural object patterns use object references to build a structure. 8
Design Patterns Classification
Behavioral
•Behavioural patterns are used to distribute responsibility between classes
and objects.
•The patterns define how the classes and objects should interact, and what
responsibilities each participant has.
•Behavioural class patterns are based on inheritance. They are mostly
concerned with handling algorithms and flow of control.
•Behavioural object patterns describe how objects can cooperate to carry
out tasks that no single object can carry out alone 9
Pros/Cons of Design Patterns
• Pros
• Add consistency to designs by solving similar problems the same
way, independent of language
• Add clarity to design and design communication by enabling a
common vocabulary
• Improve time to solution by providing templates which serve as
foundations for good design
• Improve reuse through composition
10
Pros/Cons of Design Patterns
• Cons
• Some patterns come with negative consequences (i.e. object
proliferation, performance hits, additional layers)
• Consequences are subjective depending on concrete scenarios
• Patterns are subject to different interpretations,
misinterpretations, and philosophies
• Patterns can be overused and abused  Anti-Patterns

11
Popular Design Patterns
• Let’s take a look
• Strategy
• Singleton
• Observer
• Decorator
• Proxy
• Façade
• Adapter
12
Strategy Definition

Defines a family of algorithms, encapsulates


each one, and makes them interchangeable.
Strategy lets the algorithm vary
independently from clients that use it.

13
Design Principles
• Identify the aspects of your application that vary and separate
them from what stays the same
• Program to an interface, not an implementation
• Favor composition over inheritance

14
Strategy
• Pros
• Provides encapsulation
• Hides implementation
• Allows behavior change at runtime
• Cons
• Results in complex, hard to understand code if overused

15
Singleton Definition

Ensure a class only has one instance and


provide a global point of access to it.

16
Singleton
• Pros
• Increases performance
• Prevents memory wastage
• Increases global data sharing
• Cons
• Results in multithreading issues

17
Thank You!

You might also like