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

CSC310 Lecture 09

CSC310 Lecture 09

Strategy, Decorator, Observer, and Singleton
(20260925)

Javier Gonzalez-Sanchez PRO

October 04, 2026

Transcript

58 slides
  1. CSC 3100 Fundamentals of Software Engineering Lecture 09. Strategy, Decorator,

    and Observer Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.phd ffi o ce: 14 -227
  2. Agenda • This is Week 06 • Week 08 -

    Mond y October 12 - Midterm Review a a a • Wednesd y October 14 - Midterm Ex m
  3. Patterns in our Sprint 2 libraries Builder XChart How do

    I construct a complex object clearly? Factory JFreeChart / Jzy3D Centralize object creation Strategy Tribuo Swap the algorithm Decorator Swing, Files, etc Wrap and augment behavior
  4. Example • InputStre m input = new FileInputStre m("d t

    .txt"); • → re ds from ile • Bu eredInputStre m inputBu ered = new Bu eredInputStre m(input); • → dds bu ering • D t InputStre m inputBu eredD t = new D t InputStre m(inputBu ered ); ff a a a a a a ff a a a a a ff ff a f a a a ff a a a a a a → dds re dInt(), re dDouble(), re dBoole n(), etc. ff a •
  5. • JButton button - new JButton("Click me") • JTextField inputText

    - new JTextField("Write here") a a a a a a a a a a a a a a • p nel. dd( notherP nel); • p nel. dd(button); • notherP nel. dd(inputText); a a • JP nel p nel = new JP nel(); • JP nel notherP nel = new JP nel();
  6. Decorator vs Inheritance • Both llow you to ch nge

    how n object beh ves. • The decor tor p ttern llows you to extend (decor te) the function lity of n object t runtime. a a a a a a a a a a a a a a a a • Inherit nce dds beh vior t compil tion time.
  7. ...

  8. Main dr w dr w dr w a a a

    https://github.com/CSC3100/Patterns
  9. Decorator vs Inheritance • Both llow you to ch nge

    how n object beh ves. • The decor tor p ttern llows you to extend (decor te) the function lity of n object t runtime. a a a a a a a a a a a a a a a a • Inherit nce dds beh vior t compil tion time.
  10. Important Do not reinvent the wheel! (Do not make another

    implementation for classes Observer or Observable -they already exist in libraries!)
  11. Warning Do not Abuse of the Singleton You are transforming

    OOP into Structural Programming!! 🙈
  12. CSC 3100 Fundamentals of Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected]

    Fall 2026 Copyright Notice. These slides are provided exclusively for educational use in CSC 3100 within the California State University system. Redistribution or use for any other purpose is prohibited without prior written permission.

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming