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

CSC307 Lecture 12

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

CSC307 Lecture 12

Introduction to Software Engineering
Decorator and Composite
(202602)

Avatar for Javier Gonzalez-Sanchez

Javier Gonzalez-Sanchez PRO

February 15, 2026
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 307 Introduction to Software Engineering Lecture 12. Patterns II
  2. Decorator vs Inheritance • Both a llow you to ch

    a nge how a n object beh a ves. • The decor a tor p a ttern a llows you to extend (decor a te) the function a lity of a n object a t runtime. • Inherit a nce a dds beh a vior a t compil a tion time. 12
  3. Decorator abstract class Decorator extends Component { protected Component component;

    public void setComponent(Component component) { this.component = component; } @override public void operation() { if (component != null) { component.operation(); } } } 20 https://github.com/CSC3100/Patterns
  4. Main 23 dr a w dr a w dr a

    w https://github.com/CSC3100/Patterns
  5. Decorator vs Inheritance • Both a llow you to ch

    a nge how a n object beh a ves. • The decor a tor p a ttern a llows you to extend (decor a te) the function a lity of a n object a t runtime. • Inherit a nce a dds beh a vior a t compil a tion time. 25
  6. Application | Observer 31 Main JFrame ChartPanel Thread <<Singleton>> Board

    Genius JPanel PropertyChange Listener PropertyChange Support
  7. CSC 307 Introduction to Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected]

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