$30 off During Our Annual Pro Sale. View Details »

CSC307 Lecture 11

CSC307 Lecture 11

Introduction to Software Engineering
Design Patterns II
(202307)

Javier Gonzalez-Sanchez
PRO

July 10, 2023
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. jgs
    CSC 307
    Introduction to Software Engineering
    Lecture 11:
    Design Patterns II
    Dr. Javier Gonzalez-Sanchez
    [email protected]
    www.javiergs.com
    Building 14 -227
    Office Hours: By appointment

    View Slide

  2. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 3
    GoF Patterns

    View Slide

  3. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 4
    Scenario 1

    View Slide

  4. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 5
    Scenario 2

    View Slide

  5. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 6
    Scenario 3

    View Slide

  6. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 7
    Key Idea
    Observer vs. Listener

    View Slide

  7. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 8
    GoF Patterns

    View Slide

  8. jgs
    Singleton

    View Slide

  9. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 10
    Singleton

    View Slide

  10. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 11
    class MainApp {
    public static void Main(String []a){
    Singleton s1 = Singleton.getInstance();
    Singleton s2 = Singleton.getInstance();
    // Test for same instance
    if (s1 == s2){
    // true - Objects are the same instance
    }
    }
    }
    Singleton

    View Slide

  11. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 12
    class Singleton{
    private static Singleton _instance;
    private Singleton() {}
    public static Singleton getInstance(){
    if (_instance == null){
    _instance = new Singleton();
    }
    return _instance;
    }
    }
    Singleton

    View Slide

  12. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 13
    Let’s Work

    View Slide

  13. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 14
    Project – User create dots

    View Slide

  14. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 15
    Project – User selects Cluster and clicks Run

    View Slide

  15. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 16
    Project – User selects Cluster and clicks Run

    View Slide

  16. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 17
    Project – User selects Line and clicks Run

    View Slide

  17. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 18
    Project – User selects Line and clicks Run

    View Slide

  18. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 19
    Project – User selects Line and clicks Run


    View Slide

  19. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 20
    Project – User selects Cluster and clicks Run


    View Slide

  20. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 21
    Questions

    View Slide

  21. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 22
    Office Hours
    Tuesday and Thursday 3 - 5 pm
    But an appointment required
    Sent me an email – [email protected]

    View Slide

  22. jgs

    View Slide

  23. jgs
    CSC 307
    Introduction to Software Engineering
    Lab 11:
    Getting Started with Assignment 02
    Dr. Javier Gonzalez-Sanchez
    [email protected]
    www.javiergs.com
    Building 14 -227
    Office Hours: By appointment

    View Slide

  24. jgs
    Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 | 25
    Let’s Work

    View Slide

  25. jgs
    CSC 307 Introduction to Software Engineering
    Javier Gonzalez-Sanchez, Ph.D.
    [email protected]
    Summer 2023
    Copyright. These slides can only be used as study material for the class CSC308 at Cal Poly.
    They cannot be distributed or used for another purpose.

    View Slide