Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC307 Lecture 07

CSC307 Lecture 07

Introduction to Software Engineering
Design Patterns
(202407)

This lecture explores the use of design patterns, emphasizing their definitions and the importance of reusable designs in real-world applications, particularly those from the Gang of Four (GoF) patterns. We will focus on the observer, singleton, decorator, and composite patterns. Diverse practical examples and code references are provided.

Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info office: 14 -227 CSC 307

    Introduction to Software Engineering Lecture 07. Patterns
  2. Definition • Design patterns are solutions to software design problems

    you find again and again in real-world application development. • Patterns are about reusable designs and interactions between objects. • The 23 Gang of Four (GoF) patterns are generally considered the foundation for all other patterns (Gamma, Helm, Johnson, and Vlissides). 12
  3. Important 26 Do not reinvent the wheel! (Do not make

    another implementation for classes Observer or Observable -they already exist in libraries!)
  4. Problem • Imagine a class Teacher running in its own

    execution thread, forever grading—recording grades as a collection of numerical values. • A panel (PrinterPanel) would like to show the grades as they are generated. • Another panel (StatisticalPanel) would like to show real-time statistics about the grades (how many pass and how many fail). 34
  5. Warning 40 Do not Abuse of the Singleton You are

    transforming OOP into Structural Programming!! !
  6. Decorator vs Inheritance • Both allow you to change how

    an object behaves. • The decorator pattern allows you to extend (decorate) the functionality of an object at runtime. • Inheritance adds behavior at compilation time. 57
  7. CSC 307 Introduction to Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected]

    Summer 2024 Copyright. These slides can only be used as study material for the class CSC307 at Cal Poly. They cannot be distributed or used for another purpose.