Software Architecture and Design BITS C461/IS C341 Software Engineering First Semester 2003-2004 Aditya P. Mathur Department of Computer Science Purdue.

Slides:



Advertisements
Similar presentations
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Design Patterns CS 406 Software Engineering I Fall 2001 Aditya P. Mathur Purdue University October 30, 2001.
Softwaretechnologie für Fortgeschrittene Teil Thaller Stunde VI: Software Engineering II Köln 22. Januar 2015.
 Recent researches show that predicative programming can be used to specify OO concepts including classes, objects, interfaces, methods, single and multiple.
The Observer Pattern SE-2811 Dr. Mark L. Hornick 1.
Observer Method 1. References Gamma Erich, Helm Richard, “Design Patterns: Elements of Reusable Object- Oriented Software” 2.
Chapter 7 – Object-Oriented Design
CSE3308/CSC Software Engineering: Analysis and DesignLecture 5B.1 Software Engineering: Analysis and Design - CSE3308 Patterns CSE3308/CSC3080/DMS/2000/12.
Reza Gorgan Mohammadi AmirKabir University of Technology, Department of Computer Engineering & Information Technology Advanced design.
Observer Pattern Fall 2005 OOPD John Anthony. What is a Pattern? “Each pattern describes a problem which occurs over and over again in our environment,
CSE Software Engineering: Analysis and Design, 2002Lecture 7B.1 Software Engineering: Analysis and Design - CSE3308 Patterns CSE3308/DMS/2002/15.
Softwaretechnologie für Fortgeschrittene Teil Thaller Stunde V: Software Engineering II Köln 28. Januar 2010.
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Design Patterns.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAM DESIGN WITH C++ Model View.
An Introduction to Software Architecture
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
SOFTWARE DESIGN (SWD) Instructor: Dr. Hany H. Ammar
Observer Behavioral Pattern. Intent Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified.
SOFTWARE DESIGN Design Concepts Design is a meaningful engineering representation of something that is to be built It can be traced to a customer’s requirements.
Behavioral Pattern: Observer C h a p t e r 5 – P a g e 186 A large monolithic design does not scale well as additional graphical and monitoring requirements.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 11 Slide 1 Design.
GRASP: Designing Objects with Responsibilities
Design Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
Manali Joshi1 The Observer Design Pattern Presented By: Manali Joshi.
Model View Controller Architectural Pattern and Observer Pattern
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern.
February 19, February 19, 2016February 19, 2016February 19, 2016 Azusa, CA Sheldon X. Liang Ph. D. Software Engineering in CS at APU Azusa Pacific.
Slide design: Dr. Mark L. Hornick
OBSERVER PATTERN OBSERVER PATTERN Presented By Presented By Ajeet Tripathi ISE
The Observer Design Pattern Author :Erich Gamma, et al. Source :Elements of Reusable Object-Oriented Software Speaker : Chiao-Ping Chang Advisor : Ku-Yaw.
February 23, 2009Observer Pattern, OOA&D, Rubal Gupta, CSPP, Winter ‘09 Observer Pattern Defines a “one-to-many” dependency between objects so that when.
Design Concepts ch-8
GRASP – Designing Objects with Responsibilities
7. Modular and structured design
Design Patterns: MORE Examples
Software Design Refinement Using Design Patterns
Coupling and Cohesion Rajni Bhalla.
Chapter 5 – Design and Implementation
Chapter 7 – Object-Oriented Design
Slide design: Dr. Mark L. Hornick
Conception OBJET GRASP Patterns
Observer Design Pattern
Lecture 9- Design Concepts and Principles
TK2023 Object-Oriented Software Engineering
Presented by Igor Ivković
CIS 375 Bruce R. Maxim UM-Dearborn
Design Patterns - A few examples
Web Programming Language
CS223: Software Engineering
Informatics 122 Software Design II
Advanced Program Design with C++
Observer Pattern 1.
Software Architecture
Lecture 9- Design Concepts and Principles
Starting Design: Logical Architecture and UML Package Diagrams
Analysis models and design models
An Introduction to Software Architecture
Introduction to Pattern Oriented Analysis and Design (POAD)
CS 8532: Advanced Software Engineering
OBJECT ARCHITECTURE DESIGN
8. Observer Pattern SE2811 Software Component Design
Week 6, Class 2: Observer Pattern
Informatics 122 Software Design II
Design Yaodong Bi.
Presented by Igor Ivković
From Use Cases to Implementation
Presentation transcript:

Software Architecture and Design BITS C461/IS C341 Software Engineering First Semester Aditya P. Mathur Department of Computer Science Purdue University Last update: September 2, 2003

September 3, 2003Software Architecture and Design2 Organization Part I: Design principles Part II:Design Patterns-I Part III:OO Design Part IV:Design Patterns-II

September 3, 2003Software Architecture and Design3 Learning Objectives To understand the basic principles of and techniques for software architecture and design.

September 3, 2003Software Architecture and Design4 What is Architecture? Organization of a software system Components within the system. Interfaces of the components and their interconnection. Collaborations amongst components.  Involves the identification of those functional and non-functional requirements that have a significant impact on the system design. Examples:  Performance  Cost  Maintainability  Points of evolution

September 3, 2003Software Architecture and Design5 Architecture [2] Analogy: Describe the architecture of: Your favorite Concerto or a Carnatik Kriti Your favorite play Your favorite home

September 3, 2003Software Architecture and Design6 Architecture [3] Software components-OO View: Application (System) A subsystem An object A method A data item

September 3, 2003Software Architecture and Design7 Architecture [4] Software components-Functional View: Application A Subsystem A function A data item Do you understand the differences between a class, an object, and a function? Between a function and a method?

September 3, 2003Software Architecture and Design8 What is Design? As a process: The process by which the architecture of a software system is established. As an artifact: The architecture of a software system describing system components and their interactions.

September 3, 2003Software Architecture and Design9 Analysis and Design Analysis: Focus on…. Understanding, refining, and specifying requirements. “What” are domain processes, concepts, terms, operations? Design: Focus on…. “How” can the requirements be met?

September 3, 2003Software Architecture and Design10 Design Phase Refine Plan Sync Artifacts AnalyzeDesignConstructTest

September 3, 2003Software Architecture and Design11 Design Principles [1] Design for change Change of algorithms Change of data representation Change of underlying abstract machine Change of peripheral devices Change of social environment

September 3, 2003Software Architecture and Design12 Design Principles [2] Separation of concerns Separation over time. Separation of quality attributes: e.g. performance and correctness Separation by parts of the system. Separation by views: e.g. data and control flows.

September 3, 2003Software Architecture and Design13 Coupling [1] Class C1 is coupled to class C2 if C1 requires C2 directly or indirectly. Coupling measures the strength of dependence between classes and packages. Measure of interconnectedness.

September 3, 2003Software Architecture and Design14 Coupling [2] High couplingLow coupling

September 3, 2003Software Architecture and Design15 Coupling [3] Design with low coupling A class that depends on 2 other classes has a lower coupling than a class that depends on 8 other classes. Why low coupling?...Leads to easier changes, easier understanding, and easier re-use.

September 3, 2003Software Architecture and Design16 Cohesion [1] Cohesion measures the strength of the relationship amongst elements of a class. When methods within a class use a “similar” set of instance variables, the class is considered highly cohesive.

September 3, 2003Software Architecture and Design17 Cohesion [2] High cohesion and low coupling is preferred. (Example: Electric subsystem of a home.) All operations and data within a class should naturally “belong” to the concept the class models. Classes with high cohesion can often be described by a simple sentence.

September 3, 2003Software Architecture and Design18 Types of cohesion Coincidental : No meaningful relationship amongst elements of a class. May occur when a program is “modularized” by chopping it into pieces and making each piece a module.  Logical cohesion : Elements of a class perform one kind of a logical function, e.g. interfacing with the Point of Sale terminal hardware.  Temporal cohesion : All elements of a class are executed “together”.

September 3, 2003Software Architecture and Design19 Design Patterns [1] A solution to a problem that occurs repeatedly in a variety of contexts.  Each pattern has a name.  Use of each pattern has consequences.

September 3, 2003Software Architecture and Design20 Design Patterns [2] Generally at a “higher level” of abstraction.  Not about designs such as linked lists or hash tables.  Generally descriptions of communicating objects and classes.

September 3, 2003Software Architecture and Design21 Observer Pattern [1]  Need to separate presentational aspects with the data, i.e. separate views and data.  Classes defining application data and presentation can be reused.  Change in one view automatically reflected in other views. Also, change in the application data is reflected in all views.  Defines one-to-many dependency amongst objects so that when one object changes its state, all its dependents are notified.

September 3, 2003Software Architecture and Design22 Observer Pattern [2] A=10% B=40% C=30% D=20% Application data A B C D ADCB Relative Percentages Y X Z A B C D Change notification Requests, modifications

September 3, 2003Software Architecture and Design23 Observer Pattern [3] Subject attach (Observer) detach (Observer) Notify () Observer Update() Concrete Observer Update() observerState Concrete Subject GetState() SetState() subjectState observers subject For all x in observers{ x  Update(); } observerState= subject  getState();

September 3, 2003Software Architecture and Design24 Class collaboration in Observer : ConcreteSubject :ConcreteObserver-1:ConcreteObserver-2 GetState() Notify() Update() SetState() GetState() Update()

September 3, 2003Software Architecture and Design25 Observer Pattern: Observer code class Subject; class observer { public: virtual ~observer; protected: virtual void Update (Subject* theChangedSubject)=0; observer (); Note the support for multiple subjects. }; Abstract class defining the Observer interface.

September 3, 2003Software Architecture and Design26 Observer Pattern: Subject Code [1] class Subject { public: virtual ~Subject; protected: Subject (); virtual void Attach (observer*); virtual void Detach (observer*) ; virtual void Notify(); private: List *_observers; }; Abstract class defining the Subject interface.

September 3, 2003Software Architecture and Design27 Observer Pattern: Subject Code [2] void Subject :: Attach (Observer* o){ _observers -> Append(o); } void Subject :: Detach (Observer* o){ _observers -> Remove(o); } void Subject :: Notify (){ ListIterator iter(_observers); } for ( iter.First(); !iter.IsDone(); iter.Next()) { iter.CurrentItem() -> Update(this); }

September 3, 2003Software Architecture and Design28 Observer Pattern: A Concrete Subject [1] class ClockTimer : public Subject { public: virtual int GetHour(); } virtual int GetMinutes(); virtual int GetSecond(); ClockTimer(); void Tick ();

September 3, 2003Software Architecture and Design29 Observer Pattern: A Concrete Subject [2] ClockTimer :: Tick { // Update internal time keeping state. // gets called on regular intervals by an internal timer. } Notify();

September 3, 2003Software Architecture and Design30 Observer Pattern: A Concrete Observer [1] class DigitalClock: public Widget, public Observer { public: DigitalClock(ClockTimer*); virtual ~DigitalClock(); virtual void Draw(); private: } ClockTimer* _subject; virtual void Update(Subject*); Override Observer operation.Override Widget operation.

September 3, 2003Software Architecture and Design31 Observer Pattern: A Concrete Observer [2] DigitalClock ::DigitalClock (ClockTimer* s) { _subject = s; } _subject  Attach(this); DigitalClock ::~DigitalClock() { _subject->Detach(this); }

September 3, 2003Software Architecture and Design32 Observer Pattern: A Concrete Observer [3] void DigitalClock ::Update (subject* theChangedSubject ) { If (theChangedSubject == _subject) { } Draw(); } void DigitalClock ::Draw () { int hour = _subject->GetHour(); } int minute = _subject->GeMinute(); // etc. Check if this is the clock’s subject. // Code for drawing the digital clock.

September 3, 2003Software Architecture and Design33 Observer Pattern: Main (skeleton) ClockTimer* timer = new ClockTimer; DigitalClock* digitalClock = new DigitalClock (timer);

September 3, 2003Software Architecture and Design34 When to use the Observer Pattern?  When an abstraction has two aspects: one dependent on the other. Encapsulating these aspects in separate objects allows one to vary and reuse them independently.  When a change to one object requires changing others and the number of objects to be changed is not known.  When an object should be able to notify others without knowing who they are. Avoid tight coupling between objects.

September 3, 2003Software Architecture and Design35 Observer Pattern: Consequences  Abstract coupling between subject and observer. Subject has no knowledge of concrete observer classes. (What design principle is used?)  Support for broadcast communication. A subject need not specify the receivers; all interested objects receive the notification.  Unexpected updates: Observers need not be concerned about when then updates are to occur. They are not concerned about each other’s presence. In some cases this may lead to unwanted updates.

September 3, 2003Software Architecture and Design36 Summary Reference for the Observer Pattern: Design patterns by Gamma et al., 1995, Chapter 5, Or read pp from Larman’s book. 4. What are the general principles of design ? 3. Where does design fit in a development process? 1.What is design? 2.What is architecture?