Responsibilities and Rewards: Reasoning about Design Patterns Neelam Soundarajan Computer Science & Engineering Ohio State University Joint work with Jason.

Slides:



Advertisements
Similar presentations
Configuration management
Advertisements

Design by Contract.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Topics in OO, Design Patterns, Reasoning About Program Behavior... (part 4) Neelam Soundarajan Computer Sc. & Eng.
Evaluating Requirements. Outline Brief Review Stakeholder Review Requirements Analysis Summary Activity 1.
Using the Crosscutting Concepts As conceptual tools when meeting an unfamiliar problem or phenomenon.
POAD Book: Chapter 10 POAD: The Design Refinement Phase Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
 Recent researches show that predicative programming can be used to specify OO concepts including classes, objects, interfaces, methods, single and multiple.
Observer Method 1. References Gamma Erich, Helm Richard, “Design Patterns: Elements of Reusable Object- Oriented Software” 2.
Design Patterns Pepper. Find Patterns Gang of Four created 23 Siemens published another good set x
Chapter 7 – Object-Oriented Design
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
Spring 2010ACS-3913 Ron McFadyen1 Weather Station Page 39+ In this application, weather station devices supply data to a weather data object. As the data.
Constructing a Case for a Proposition International Debate Education Association.
Introduction to Databases
March Ron McFadyen1 Design Patterns In software engineering, a design pattern is a generally repeatable solution to a commonly-occurring problem.
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
CSC 395 – Software Engineering Lecture 21: Overview of the Term & What Goes in a Data Dictionary.
1 Software Requirements Specification Lecture 14.
1 Object Oriented Design & Patterns Part 1. 2 Design Patterns Derived from architectural patterns: –rules for design of buildings –describe common problems,
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
ACOS 2010 Standards of Mathematical Practice
An Intelligent Broker Architecture for Context-Aware Systems A PhD. Dissertation Proposal in Computer Science at the University of Maryland Baltimore County.
Design Patterns.
Lecture 16 March 22, 2011 Formal Methods CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
المحاضرة الثالثة. Software Requirements Topics covered Functional and non-functional requirements User requirements System requirements Interface specification.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
Introduction to the Unified Modeling Language “The act of drawing a diagram does not constitute analysis or design. … Still, having a well-defined and.
Configuration Management (CM)
POAD Book: Chapter 9 POAD: The Design Phase Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Computer Science and Engineering College of Engineering The Ohio State University Interfaces The credit for these slides goes to Professor Paul Sivilotti.
1 Science as a Process Chapter 1 Section 2. 2 Objectives  Explain how science is different from other forms of human endeavor.  Identify the steps that.
POSL (Principles of Software Languages) Gr. Kyushu Institute of Technology, Japan Pointcut-based Architectural Interface.
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
Lecture 7: Requirements Engineering
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Automating the Development of Pattern-Oriented Designs Copyright, 1996 © Dale Carnegie & Associates, Inc. Sherif Yacoub, Hengyi Xue, and Hany Ammar {yacoub,
A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.
Neelam Soundarajan 1 Johan Dovland 2 Jason Hallstrom 3 Tracing Correct Usage of Design Patterns 2 Computer Sc. Dept. Clemson University 1 Computer Sc.
Logical view –show classes and objects Process view –models the executables Implementation view –Files, configuration and versions Deployment view –Physical.
Introduction to Earth Science Section 2 Section 2: Science as a Process Preview Key Ideas Behavior of Natural Systems Scientific Methods Scientific Measurements.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Lecture PowerPoint Slides Basic Practice of Statistics 7 th Edition.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
Winter 2007SEG2101 Chapter 31 Chapter 3 Requirements Specifications.
Software Requirements Specification Document (SRS)
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Requirement engineering & Requirement tasks/Management. 1Prepared By:Jay A.Dave.
Chapter 8 Object Design Reuse and Patterns. More Patterns Abstract Factory: Provide manufacturer independence Builder: Hide a complex creation process.
Capturing Requirements. Questions to Ask about Requirements 1)Are the requirements correct? 2)Consistent? 3)Unambiguous? 4)Complete? 5)Feasible? 6)Relevant?
Semantic Web in Context Broker Architecture Presented by Harry Chen, Tim Finin, Anupan Joshi At PerCom ‘04 Summarized by Sungchan Park
POAD Book: Chapter 7 POAD: The Process Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
DBC NOTES. Design By Contract l A contract carries mutual obligations and benefits. l The client should only call a routine when the routine’s pre-condition.
Course: Software Engineering – Design I IntroductionSlide Number 1 What is a specification Description of a (computer) system, which:  is precise;  defines.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
A UML-Based Pattern Specification Technique Presented by Chin-Yi Tsai IEEE TRANSACTION ON SOFTWARE ENGINEERING, VOL. 30, NO. 3, MARCH 2004 Robert B. France,
Design Refinement: From Patterns to System Implementation Neelam Soundarajan 1 Computer Science & Engineering Ohio State University ( 1 Joint work with.
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 by Contract Jim Fawcett CSE784 – Software Studio
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
Web Programming Language
Introduction Artificial Intelligent.
Observer Pattern 1.
ISpec: A Compositional Approach to Interface Specification
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Formal Methods Lecture 16 March 22, 2011 CS 315 Spring 2011
Presentation transcript:

Responsibilities and Rewards: Reasoning about Design Patterns Neelam Soundarajan Computer Science & Engineering Ohio State University Joint work with Jason Hallstrom, Ben Tyler,...

Reasoning About Design Patterns2 What is a Design Pattern? Fact: Variations of the same problem appear in different systems. Fact: A core solution –a pattern– can be used to solve such problems.

Reasoning About Design Patterns3 Example... Common Problem: Need to keep the states of a set of objects consistent with that of another object.

Attach(in Obs) Detach(in Obs) ConcreteSubject -subjectState 1 subject * ConcreteObserver -observerState Update() Notify() For all o in observers o.Update() Idea:When Subject state changes, call Notify(). Notify() calls Update() on each Observer. Each Observer has to update its state to make it consistent with the new Subject state. observers *1 ObserverSubject Solution: Observer Pattern:

Reasoning About Design Patterns5 Why use patterns? Exploits collective wisdom of community Common vocabulary for designers Reuse of designs, not just code.

Reasoning About Design Patterns6 Background Patterns allow designers to design and document their designs. New designers can get a good idea of how a system is designed and why it behaves in certain ways...

Reasoning About Design Patterns7 Background (contd.) Patterns are usually described informally Many pattern catalogs (GoF, POSA1, POSA2,...) Informal descriptions are very useful, but...

Reasoning About Design Patterns8 Thesis... To fully realize the benefits of patterns, we must have precise specs else possibility of conflicting interpretations of how to apply a pattern... or how to make changes to a system,...

Reasoning About Design Patterns9 Potential Risk in Formalizing... Flexibility may be lost! My goal: Find a way to provide precise specs while retaining flexibility.

Reasoning About Design Patterns10 Talk Outline What is a design pattern? Example: Observer pattern Background Problems with informal descriptions of Observer Roles, auxiliary concepts,... Specification of Observer Future work...

Attach(in Obs) Detach(in Obs) ConcreteSubject -subjectState 1 subject * ConcreteObserver -observerState Update() Notify() For all o in observers o.Update() Idea:When Subject state changes, call Notify(). Notify() calls Update() on each Observer. Each Observer has to update its state to make it consistent with the new Subject state. observers *1 ObserverSubject Solution: Observer Pattern:

Reasoning About Design Patterns12 But... What does “change in subject state” mean? Change in a single bit/byte? Std. ans.: Subject notifies observers when a change occurs that could make its state inconsistent with that of an observer. But how will the subject know this has happened?

Reasoning About Design Patterns13 And, moreover... What does inconsistent mean, anyway? Further: If we apply pattern correctly, what can we expect in return?

Reasoning About Design Patterns14 Goal of the research... Provide precise answers to such questions

Reasoning About Design Patterns15 Potential Risk... If we use one particular precise meaning of consistent or change in our formalization, the pattern may not be applicable in other situations.

Reasoning About Design Patterns16 Important Observations... A pattern consists of a number of roles... Subject and Observer in our case. Particular objects play particular roles.

Reasoning About Design Patterns17 Pattern Instances There may be several instances of a pattern at a given time (during execution). E.g.: s1, o1, o2 may form one instance; s2, o3, o4, o5 may form another. o1 and o3 may be the same object. (Same object can’t play two roles in the same instance.)

Reasoning About Design Patterns18 Key Ideas Auxiliary concepts: represent notions such as consistency, change in state, etc. Actual definition of AC’s will be specific to pattern instance. Pattern spec will be in terms of AC’s

Reasoning About Design Patterns19 Key Ideas (contd.) Pattern spec will impose constraints on the ACs. The reward of using the pattern will be in terms of an invariant over all the objects playing roles in the pattern.

Reasoning About Design Patterns20 Some Details... Spec consists of a pattern-level portion, & a role-specific portion (for each role). Pattern-level: role names, state for each role; auxiliary concepts, constraints on them; conditions for creating new pattern instance, enrolling in various roles; invariant –the reward– for using the pattern.

Reasoning About Design Patterns21 Some Details (contd.) For each role: pre- and post- conditions for each method that the role must provide. conditions for other methods of the role. All of these in terms of role’s state component and ACs.

Reasoning About Design Patterns22 Observer Pattern Spec: Pattern-level pattern Observer { roles: Subject, Observer*; state: Subject: set [Observer] _observers; Observer: Subject _subject;

Reasoning About Design Patterns23 Pattern-level Spec (contd.) auxiliary concepts: Consistent( Subject, Observer); Modified( Subject, Subject ); constraint: [~Modified(as1, as2) && Consistent(as1, ao1)] ==> Consistent(as2, ao1)

24 Pattern-level Spec (contd.) invariant: (forall ob IN _observers): Consistent(subject.st, ob.st); instantiation: Subject enrollment: // not allowed Observer enrollment:

Reasoning About Design Patterns25 Role-level Spec: Subject role spec Subject { methods: void Attach(Observer ob): requires: (ob = caller) // Omit this? preserves: as;// “application state” ensures: (_observers = U {ob}) &&

Role-level Spec: Subject (contd) others: preserves: _observers; ensures: this)] OR [exists k: [ cs[k].m = Notify ] ] //Bug! this)] OR [exists k: [ cs[k].m = Notify ] && [~Modified(cs[k].st, this)] && [forall j>k: cs[j].m != Notify] ]

Role-level Spec: Observer role spec Observer { methods: void Update(): requires: true; preserves: _subject; ensures: Consistent(_subject.as, this) others: preserves: _subject; ensures: Consistent(_subject.as, this)

Reasoning About Design Patterns28 Some Key Lessons Formalizing patterns allowed us to identify/eliminate potential problems: Incompatibility between Modified and Consistent Failing to make the Observer consistent with the Subject on attaching.

Reasoning About Design Patterns29 Key Lessons (contd) Formalizing allowed us to enhance flexibility: Standard descriptions suggest: no change in Observer except by Update(). Not necessary! Consistent() provides a more flexible requirement. Similar situation for other patterns.

Reasoning About Design Patterns30 Current and Future Work Run-time monitoring of systems to check violations of pattern contracts. Creating tests to check satisfaction of pattern contracts. Visualization of pattern instances. Consider patterns for distributed computing. Etc.

Reasoning About Design Patterns31 Thanks! Questions? Slides available at:.../~neelam/TALKS/885Oct1210Talk.ppt Papers at:.../~neelam/papers

Reasoning About Design Patterns32 Thanks! Questions? Slides available at:.../~neelam/TALKS/885Oct1210Talk.ppt Papers at:.../~neelam/papers

Reasoning About Design Patterns33 Thanks! Questions? Slides available at:.../~neelam/TALKS/885Oct1210Talk.ppt Papers at:.../~neelam/papers

Reasoning About Design Patterns34 Thanks! Questions? Slides available at:.../~neelam/TALKS/885Oct1210Talk.ppt Papers at:.../~neelam/papers

Subject Attach(in Obs) Notify() Detach(in Obs) observers *1 ConcreteSubject -subjectState 1 subject * Observer Update() ConcreteObserver -observerState Update() For all o in observers o.Update() Idea:When Subject state changes, call Notify(). Notify() calls Update() on each Observer. Each Observer has to update its state to make it consistent with the new Subject state. Solution: Observer Pattern: Subject Attach(in Obs) Notify() Detach(in Obs)