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

Design Patterns - 3

The document provides an overview of software re-engineering concepts, focusing on object-oriented principles and design patterns such as Observer, Decorator, Proxy, Façade, and Adapter. It discusses the definitions, pros and cons of each pattern, and emphasizes design principles like separation of concerns and programming to an interface. The conclusion highlights the importance of good design for maintainability, extensibility, and reusability, supported by references to key literature in the field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Design Patterns - 3

The document provides an overview of software re-engineering concepts, focusing on object-oriented principles and design patterns such as Observer, Decorator, Proxy, Façade, and Adapter. It discusses the definitions, pros and cons of each pattern, and emphasizes design principles like separation of concerns and programming to an interface. The conclusion highlights the importance of good design for maintainability, extensibility, and reusability, supported by references to key literature in the field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

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
Observer Definition

Defines a one-to-many dependency between


objects so that when one object changes
state, all of its dependents are notified and
updated automatically.

4
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
• Strive for loosely coupled designs between objects that interact

University of Kansas 02/08/25


Observer
• Pros
• Abstracts coupling between Subject and Observer
• Supports broadcast communication
• Supports unexpected updates
• Enables reusability of subjects and observers independently of
each other
• Cons
• Exposes the Observer to the Subject (with push)
6
• Exposes the Subject to the Observer (with pull)
Patterns & Definitions – Group 1
• Strategy • Allows objects to be notified
• Observer when state changes
• Singleton • Ensures one and only one
instance of an object is created
• Encapsulates inter-changeable
behavior and uses delegation to
decide which to use

University of Kansas 02/08/25


Patterns & Definitions – Group 1
• Strategy • Allows objects to be notified
• Observer when state changes
• Singleton • Ensures one and only one
instance of an object is created
• Encapsulates inter-changeable
behavior and uses delegation to
decide which to use

University of Kansas 02/08/25


Decorator Definition

Attaches additional responsibilities to an


object dynamically. Decorators provide a
flexible alternative to sub-classing for
extending functionality.

9
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
• Strive for loosely coupled designs between objects that interact
• Classes should be open for extension, but closed for modification

10

University of Kansas 02/08/25


Decorator
• Pros
• Helps in building flexible systems
• Works great if coded against the abstract component type

• Cons
• Results in problems if there is code that relies on the concrete
component’s type

11
Proxy Definition

Provides a surrogate or placeholder for


another object to control access to it

12
Proxy
• Pros
• Prevents memory wastage
• Creates expensive objects on demand

• Cons
• Adds complexity when trying to ensure freshness

13
Facade Definition

Provides a unified interface to a set of


interfaces in a subsystem. Façade defines a
higher level interface that makes the
subsystem easier to use.

14
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
• Strive for loosely coupled designs between objects that interact
• Classes should be open for extension, but closed for modification
• Principle of least knowledge – talk only to your immediate friends

15

University of Kansas 02/08/25


Facade
• Pros
• Makes code easier to use and understand
• Reduces dependencies on classes
• Decouples a client from a complex system

• Cons
• Results in more rework for improperly designed Façade class
• Increases complexity and decreases runtime performance for large
number of Façade classes
16
Adapter Definition

Converts the interface of a class into another


interface the clients expect. Adapter lets
classes work together that couldn’t otherwise
because of incompatible interfaces.

17
Adapter
• Pros
• Increases code reuse
• Encapsulates the interface change
• Handles legacy code

• Cons
• Increases complexity for large number of changes

18

University of Kansas 02/08/25


Patterns & Definitions – Group 2
• Decorator • Simplifies the interface of a
• Proxy set of classes
• Façade • Wraps an object and
• Adapter provides an interface to it
• Wraps an object to provide
new behavior
• Wraps an object to control
access to it
19

University of Kansas 02/08/25


Patterns & Definitions – Group 2
• Decorator • Simplifies the interface of a
• Proxy set of classes
• Façade • Wraps an object and
• Adapter provides an interface to it
• Wraps an object to provide
new behavior
• Wraps an object to control
access to it
20

University of Kansas 02/08/25


Pattern Classification
• Strategy
• Observer
• Singleton
• Decorator
• Proxy
• Façade
• Adapter
21

University of Kansas 02/08/25


Pattern Classification
• Strategy • Behavioral
• Observer • Behavioral
• Singleton • Creational
• Decorator • Structural
• Proxy • Structural
• Façade • Structural
• Adapter • Structural
22

University of Kansas 02/08/25


Conclusion - 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
• Strive for loosely coupled designs between objects that interact
• Classes should be open for extension, but closed for modification
• Principle of least knowledge – talk only to your immediate friends

23

University of Kansas 02/08/25


Conclusion

Good Design
Maintainability
Extensibility
Scalability
Testability
Reusablilty
Design Patterns
Singleton
Abstract Factory
DAO
Strategy
Decorator

Design Principles
Program to an interface, not an implementation
High cohesion
Low coupling
Open-Closed
Separation of concerns 24
References
• Design Patterns: Elements of Reusable Object-Oriented Software. Gamma, Helm, Johnson,
and Vlissides (GoF). Addison-Wesley, 1995.
• Head First Design Patterns. Freeman and Freeman. O’REILLY, 2004.
• Design Patterns Explained. Shalloway and Trott. Addison-Wesley, 2002.
• Patterns of Enterprise Application Architecture. Fowler. Addison-Wesley, 2003.
• Core J2EE Pattern Catalog, Sun Developer Network,
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
• Object Oriented Software Construction. Meyer, Prentice Hall, 1988.

25
Thank You!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy