Topics in OO, Design Patterns, Reasoning About Program Behavior... (part 4) Neelam Soundarajan Computer Sc. & Eng.

Slides:



Advertisements
Similar presentations
Configuration management
Advertisements

Design by Contract.
De necessariis pre condiciones consequentia sine machina P. Consobrinus, R. Consobrinus M. Aquilifer, F. Oratio.
Using the Crosscutting Concepts As conceptual tools when meeting an unfamiliar problem or phenomenon.
 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
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
OASIS Reference Model for Service Oriented Architecture 1.0
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,
CS 290C: Formal Models for Web Software Lecture 10: Language Based Modeling and Analysis of Navigation Errors Instructor: Tevfik Bultan.
Software Testing and Quality Assurance
Chapter 1 Software Development. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 1-2 Chapter Objectives Discuss the goals of software development.
November 13, 2006ECEN 5543 / CSCI 5548 – Testing OO University of Colorado, Boulder 1 Testing Object-Oriented Software Principles Summary ECEN 5543 / CSCI.
Introduction to Databases
1 Software Testing and Quality Assurance Lecture 20 – Class Testing Basics (Chapter 5, A Practical Guide to Testing Object- Oriented Software)
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Design Patterns.
The Software Product Life Cycle. Views of the Software Product Life Cycle  Management  Software engineering  Engineering design  Architectural design.
Computer Science 340 Software Design & Testing Design By Contract.
An Intelligent Broker Architecture for Context-Aware Systems A PhD. Dissertation Proposal in Computer Science at the University of Maryland Baltimore County.
Design Patterns.
1 Archface: Architectural Interface -- Bridging a Gap between Design Modeling and Implementation Naoyasu Ubayashi, Hidenori Akatoki, Jun Nomura Kyushu.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
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.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Configuration Management (CM)
What is a Business Analyst? A Business Analyst is someone who works as a liaison among stakeholders in order to elicit, analyze, communicate and validate.
POSL (Principles of Software Languages) Gr. Kyushu Institute of Technology, Japan Pointcut-based Architectural Interface.
April 22, 2002VMASC Board Meeting Issues in Enhancing Simulation Model Reuse C. Michael Overstreet Richard E. Nance Osman Balci.
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
Chapter 13: Regression Testing Omar Meqdadi SE 3860 Lecture 13 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Jan. 29, 2002Grand Challenges in Simulation Issues in Enhancing Model Reuse C. Michael Overstreet Richard E. Nance Osman Balci.
Requirements as Usecases Capturing the REQUIREMENT ANALYSIS DESIGN IMPLEMENTATION TEST.
1 Software Development Software Engineering is the study of the techniques and theory that support the development of high-quality software The focus is.
Neelam Soundarajan 1 Johan Dovland 2 Jason Hallstrom 3 Tracing Correct Usage of Design Patterns 2 Computer Sc. Dept. Clemson University 1 Computer Sc.
14.1/21 Part 5: protection and security Protection mechanisms control access to a system by limiting the types of file access permitted to users. In addition,
Logical view –show classes and objects Process view –models the executables Implementation view –Files, configuration and versions Deployment view –Physical.
CSC 480 Software Engineering Design by Contract. Detail Design Road Map Begin with architectural models  Class model: domain classes  Overall state.
DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes.
1-1 Software Development Objectives: Discuss the goals of software development Identify various aspects of software quality Examine two development life.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Chapter 8 Object Design Reuse and Patterns. More Patterns Abstract Factory: Provide manufacturer independence Builder: Hide a complex creation process.
The Last Lecture CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
Object-Oriented Design Concepts University of Sunderland.
Semantic Web in Context Broker Architecture Presented by Harry Chen, Tim Finin, Anupan Joshi At PerCom ‘04 Summarized by Sungchan Park
Responsibilities and Rewards: Reasoning about Design Patterns Neelam Soundarajan Computer Science & Engineering Ohio State University Joint work with Jason.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Kyung Hee University Class Diagramming Notation OOSD 담당조교 석사과정 이정환.
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.
1 Sections 6.4 – 6.5 Methods and Variables Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
 System Requirement Specification and System Planning.
Object-Oriented Design
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
TIM 58 Chapter 8: Class and Method Design
Web Programming Language
Introduction Artificial Intelligent.
Observer Pattern 1.
ISpec: A Compositional Approach to Interface Specification
Presentation transcript:

Topics in OO, Design Patterns, Reasoning About Program Behavior... (part 4) Neelam Soundarajan Computer Sc. & Eng.

2 Background Design Patterns Time-tested solutions to recurring problems; Patterns Have fundamentally altered how s/w is designed; Allow designers to exploit the collective wisdom of the s/w community.

3 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. Advantages: Exploits collective wisdom of community; Common vocabulary for designers; Reuse of designs, not just code.

4 Example Common Problem: Need to keep the states of a set of objects consistent with that of another object. Solution: Observer Pattern

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)

6 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?

7 Moreover... What does inconsistent mean, anyway? Further: If we apply pattern correctly, what can we expect in return?

8 Goal of formalization... Provide precise answers to such questions Guiding Principle: In the same way that patterns enable designers to reuse good solutions to recurring problems, our formalism should enable designers/implementers to reuse the corresponding reasoning, testing,... efforts in ensuring that system designs are “correct”.

9 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.

10 But as it turns out... No sacrifice in flexibility... Often can identify additional flexibility dimensions (missing in standard descriptions of the patterns)! Designers can check that their implementations faithful to the underlying design (patterns). Can help system maintainers to preserve design integrity.

11 Important Observations... A pattern consists of a number of roles : Subject and Observer in Observer pattern. Particular objects play particular roles.

12 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 o2 may be the same object. (Same object can’t play two roles in the same instance.)

13 Approach Pattern P will be specified by a pattern contract PC System S designed using P will have a subcontract SPC PC specifies requirements/guarantees applicable to all systems designed using P SPC defines how P is specialized for use in S.

14 Key Ideas Auxiliary concepts: represent notions such as consistency, change in state, etc. Actual definition of AC’s --tailored to the system-- will be part of the subcontract. Pattern contract will be in terms of AC’s

15 Key Ideas (contd.) Pattern contracts will impose constraints on Auxiliary Concepts The pattern contract will specify invariants as well as conditions satisfied by various methods - provided the requirements, including the constraints, are satisfied.

16 Some Details Pattern contract: A pattern-level portion A role-specific portion (for each role). Pattern-level: role names, state for each role auxiliary concepts, constraints conditions for creating new pattern instance, enrolling in various roles pattern invariant

17 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 auxiliary concepts.

18 Observer -- Pattern level pattern Observer { roles: Subject, Observer*; state: Subject: set [Observer] _observers; Observer: Subject _subject;

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

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

21 Role contract: Subject role spec Subject { methods: void Attach(Observer ob): requires: (ob = caller) // Omit this? preserves: applState;// “application state” ensures: (_observers = U {ob}) &&

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

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

24 Some Key Points 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.

25 Some Key Points (contd.) Formalizing allowed us to enhance flexibility: Standard descriptions suggest: no change in an observer except by Update(). Not necessary! Consistent() provides a more flexible requirement. Similar situation for other patterns.

26 Open Questions Isn’t the contract for Observer too restrictive? Can’t a call to Update() change the subject state? If we want to allow for such changes, how do we ensure that only reasonable activites are allowed? Does it make sense to specify a pattern in the same style as specifying individual classes? Wouldn’t it make more sense to specify the whole group of objects involved in a pattern instance? But how? …

27 Open Questions (contd.) Are our auxiliary concepts sufficiently powerful? E.g.: Can the observers be organized in a chain so that the subject directly invokes Update() on the first observer? Or into several cohort groups? Etc.? In general: Shouldn’t we allow the pattern of interactions to be also specialized in different ways in individual applications? But how?

28 Open Questions (contd.) Pattern hierarchies: Can patterns be organized into suitable hierarchies? Would it be useful to do so? Pattern mining? There has been some work on this … Others …