CSE460 Lecture 25

CSE460 Lecture 25

Software Analysis and Design
Connecting the Dots
(202010)

B546a9b97d993392e4b22b74b99b91fe?s=128

Javier Gonzalez

July 25, 2020
Tweet

Transcript

  1. jgs CSE 460 Software Analysis and Design Lecture 25: Connecting

    the Dots Dr. Javier Gonzalez-Sanchez javiergs@asu.edu javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment
  2. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 2 jgs

    Next
  3. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 3 jgs

    Idea wrapper2 Main wrapper1 Factory decoration Envelope Box Gift wrapper3 ball Supervisor Is big > 10, box Is small < 5, envelop
  4. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 4 jgs

    Using a Factory public class Client { public static void main(String[] args) { AbstractFactory shapeFactory = new ShapeFactory(); //get an object of Shape Rectangle Shape shape1 = shapeFactory.getShape("RECTANGLE"); //call draw method of Shape Rectangle shape1.draw(); //get an object of Shape Square Shape shape2 = shapeFactory.getShape("SQUARE"); //call draw method of Shape Square shape2.draw(); ] //get shape factory AbstractFactory shapeFactory1 = new RoundedShapeFactory(); //get an object of Shape Rectangle Shape shape3 = shapeFactory1.getShape("RECTANGLE"); //call draw method of Shape Rectangle shape3.draw(); //get an object of Shape Square Shape shape4 = shapeFactory1.getShape("SQUARE"); //call draw method of Shape Square shape4.draw(); } }
  5. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 5 jgs

    Using Chain of Responsibility // Setup Chain of Responsibility Handler h1 = new ConcreteHandler1(); Handler h2 = new ConcreteHandler2(); Handler h3 = new ConcreteHandler3(); h1.SetSuccessor(h2); h2.SetSuccessor(h3); // Generate and process request int[] requests = { 2, 5, 14, 22, 18, 3, 27, 20 }; foreach (int i=0; i<requests.lenght; i++) { h1.HandleRequest(request[i]); }
  6. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 6 jgs

    Using a Decorator class MainApp { static void main() { // Create ConcreteComponent and two Decorators ConcreteComponent c = new ConcreteComponent(); ConcreteDecoratorA d1 = new ConcreteDecoratorA(); ConcreteDecoratorB d2 = new ConcreteDecoratorB(); // Link decorators d1.SetComponent(c); d2.SetComponent(d1); d2.Operation(); } }
  7. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 7 jgs

    Factory
  8. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 8 jgs

    Chain of Responsibility
  9. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 9 jgs

    Decorator
  10. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 10 jgs

    Team 1 2 3
  11. jgs CSE 460 Software Analysis and Design Javier Gonzalez-Sanchez javiergs@asu.edu

    Fall 2020 Disclaimer. These slides can only be used as study material for the class CSE460 at ASU. They cannot be distributed or used for another purpose.