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

CSC307 Lecture 09

CSC307 Lecture 09

Introduction to Software Engineering
Patterns
(202407)

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 09. Patterns
  2. De f inition • Design patterns a re solutions to

    softw a re design problems you f ind a g a in a nd a g a in in re a l-world a pplic a tion development. • P a tterns a re a bout reusable designs a nd inter a ctions between objects. • The 23 G a ng of Four (GoF) patterns a re gener a lly considered the found a tion for a ll other p a tterns (G a mm a , Helm, Johnson, a nd Vlissides). 9
  3. Warning 15 Do not Abuse of the Singleton You are

    transforming OOP into Structural Programming!! 🙈
  4. Important 28 Do not reinvent the wheel! (Do not make

    another implementation for classes Observer or Observable -they already exist in libraries!)
  5. Problem • Im a gine a cl a ss Te

    a cher running in its own execution thre a d, forever gr a ding—recording gr a des a s a collection of numeric a l v a lues. • A p a nel (PrinterP a nel) would like to show the gr a des a s they a re gener a ted. • Another p a nel (St a tistic a lP a nel) would like to show re a l-time st a tistics a bout the gr a des (how m a ny p a ss a nd how m a ny f a il). 37
  6. Code public class B implements E { public B() {

    C c1 = new C(); } public void method(X x) { x.m() B b = new B(); b.sleep(); } } public class Y { X x = new X(); B b = new B(); } public class A extends B { C c1, c2; public A() { c1 = new C(); } public void method() { D d = new D(); d.working(); } } public class X { B var = new A(); public void m() { double x – Math.sqrt(5); } }
  7. CSC 307 Introduction to Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected]

    Spring 2025 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.