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

CSC308 Lecture 15

CSC308 Lecture 15

Software Engineering I
Design Patterns - Singleton
(202302)

Javier Gonzalez-Sanchez PRO

October 28, 2022

Transcript

23 slides
  1. jgs CSC 308 Software Engineering 1 Lecture 15: Design Patterns

    - Singleton Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.com Building 14 -227 Office Hours: By appointment
  2. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    4 Project – User selects Cluster and clicks Run ✅
  3. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    5 Project – User selects Cluster and clicks Run ✅
  4. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    6 Project – User selects Line and clicks Run ✅
  5. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    7 Project – User selects Line and clicks Run ✅
  6. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    12 Think About It Can we do something about that class Repository?
  7. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

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

    17 class Singleton{ private static Singleton _instance; // Constructor is 'protected' protected Singleton() {} public static Singleton getInstance(){ if (_instance == null){ _instance = new Singleton(); } return _instance; } } Singleton
  9. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    19 Office Hours Tuesday and Thursday 3 - 5 pm But an appointment required Sent me an email – [email protected]
  10. jgs

  11. jgs CSC 308 Software Engineering 1 Lab 15: Design Patterns

    Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.com Building 14 -227 Office Hours: By appointment
  12. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    22 Ideas Do you Have Questions About Your Assignment 02?
  13. jgs CSC 308 Software Engineering I Javier Gonzalez-Sanchez, Ph.D. [email protected]

    Winter 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.

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming