Advantages of Separation of Concerns ◆Understandability ◆Maintainability ◆ Extensibility ◆Reusability ◆Adaptability ◆ Separation of Concerns directly supports quality factors. Lack of separation of concerns directly negatively impact quality factors. Object Oriented Analysis and Design 11
Object Oriented Analysis and Design 11 Advantages of Separation of Concerns w Understandability w Maintainability w Extensibility w Reusability w Adaptability w Separation of Concerns directly supports quality factors. w Lack of separation of concerns directly negatively impact quality factors
Example Figure Editor A figure consists of several figure elements. A figure element is either a point or a line. Figures are drawn on Display.A point includes X and Y coordinates.A line is defined as two points. Object Oriented Analysis and Design 12
Object Oriented Analysis and Design 12 Example - Figure Editor w A figure consists of several figure elements. A figure element is either a point or a line. Figures are drawn on Display. A point includes X and Y coordinates. A line is defined as two points
Example Figure Editor Design Display Figure 米 Components are FigureElement Cohesive A Loosely Coupled Have well-defined interfaces Point Line (abstraction,encapsulation) getx() 2 getP1 getY() setP1 setX(int) setP1(Point) setY(int) setP2(Point) Nice Modular Design! Object Oriented Analysis and Design 13
Object Oriented Analysis and Design 13 Example - Figure Editor - Design Components are - Cohesive - Loosely Coupled - Have well-defined interfaces (abstraction, encapsulation) Nice Modular Design! Display Figure FigureElement * Point Line getX() getY() getP1 setP1 setX(int) setY(int) setP1(Point) setP2(Point) 2
Crosscutting Concern Example Notify ScreenManager if a figure element moves Display Figure FigureElement Point Line getx() getP1 getY() setP1 setX(int) setP1(Point) DisplayTracking setY(int) setP2(Point) Object Oriented Analysis and Design 14
Object Oriented Analysis and Design 14 Display Figure FigureElement * Point Line getX() getY() getP1 setP1 DisplayTracking setX(int) setY(int) setP1(Point) setP2(Point) 2 Crosscutting Concern - Example Notify ScreenManager if a figure element moves
Example:Display Tracking Crosscutting Concern DisplayTracker class DisplayTracker static void updatePoint(Point p) Display this.display (p); Figure FigureElement static void updateLine(Line 1) f Point Line this.display (1); getx() getP1 getY() setP1 setx(int) setP1(Point) setY(int) setP2(Point) class Point class Line void setx(int x){ void setpl(Point pl DisplayTracker.updatePoint(this); DisplayTracker.updateLine (this); this.xx; this.p1 pl; Object Oriented Analysis and Design 15
Object Oriented Analysis and Design 15 class Point { void setX(int x) { DisplayTracker.updatePoint(this); this.x = x; } } class DisplayTracker { static void updatePoint(Point p) { this.display(p); .... } static void updateLine(Line l) { this.display(l); .... } Display Figure FigureElement * Point Line getX() getY() getP1 setP1 setX(int) setY(int) setP1(Point) setP2(Point) 2 DisplayTracker class Line { void setP1(Point p1 { DisplayTracker.updateLine(this); this.p1 = p1; } } Example: Display Tracking Crosscutting Concern