Software engineering perspectives

3


Additional keywords and phrases: requirements, analysis, implementation, design as transition, CRC cards, responsibilities, heuristics, contractual obligations, validation


slide: Software engineering perspectives

subsections:


  • OOA/D -- incremental

     [CY91b]


  • Objectory -- use-case analysis

     [Jacobs92]


  • OOSA -- model-driven

     [Kurtz90]


  • OOSD -- structured

     [Wasserman89]


  • CRC -- cards

     [BC89]


  • RDD -- responsibility-driven

     [Wirfs89]


  • OMT -- object modeling

     [Rum91]


  • OOD -- development

     [Booch91]


  • Fusion -- lifecycle

     [Fusion]


Unified Modeling Language -- standard notation

UML


  • class diagrams, object interaction, packages, state and activity

slide: Software development methods


Structured methods

tools



slide: Tools for a structured approach


Modeling reality -- vernacular

Design model -- system oriented


slide: Perspectives of modeling


Dimensions of modeling -- OMT

Model of control


slide: The OMT method


Model criteria -- formal approach


slide: Coherent models -- criteria


Analysis -- Fusion

Fusion


  • Object Model -- concepts and relations
  • LifeCycle Model -- sequences of operations
  • Operation Model -- semantics of system operations

Design -- data dictionary

data dictionary


  • Object Interaction Graph -- functional dependencies
  • Visibility Graphs -- communication structure
  • Class Descriptions -- attributes and methods
  • Inheritance Graphs -- subtype refinement

Implementation -- validation

validation


  • System Lifecycle -- state machines
  • Class Descriptions -- coding, performance

slide: The Fusion method


Objectory -- systematic process

  • requirements -- use cases, domain object model, user interface
  • analysis -- subsystems
  • design, implementation -- block model, interaction diagrams

OMT -- few rules for discovering inconsistencies

  • analysis -- object model, dynamic model, functional model
  • design, implementation -- heuristics to implement analysis models

Booch -- descriptive

  • diagrams -- class, object, timing, state, module, process

CRC -- exploratory

  • analysis, design -- class, responsibilities, collaborators

Formal methods

  • operations -- pre- and post-conditions

slide: Comparison of methods (1)


Booch


>
slide: Diagrams for design

subsections:


Object-oriented design -- decomposition into objects

Identifying objects -- responsibilities

Layers of abstraction


slide: Object-oriented design


Objects -- crisp entities

The method:


slide: The Booch method


Heuristics

Associations


slide: Heuristics for modeling


Candidate classes

ATM



slide: The ATM example (1)


Eliminating spurious classes

Good classes


slide: Eliminating spurious classes


Object-oriented thinking

CRC


OO design with CRC cards


slide: The CRC method


Object roles


slide: Object roles

analyze a little,

design a little,

implement a little,

test a little ...



slide: The Model-View-Controller paradigm

subsections:


Assertions -- formal specification


slide: Formal specification of contracts



slide: The substitutability requirement



  class account {  
account
public: account(); // assert( invariant() ); virtual float balance() { return _balance; } void deposit(float x);
to deposit money
// require( x >= 0 ); // promise( balance() == old_balance + x && invariant() ); void withdraw(float x);
to withdraw money
// require( x <= balance() ); // promise( balance() == old_balance - x && invariant() ); bool invariant() { return balance() >= 0; } protected: float _balance; };

slide: The $account$ contract


System development

A pre-condition limits the cases that a supplier must handle!


slide: System development with contracts



  class account { 
account
public: account() { _balance = 0; assert(invariant()); } virtual float balance() { return _balance; } void deposit(float x) { require( x >= 0 ); // check precondition hold(); // to save the old state _balance += x; promise( balance() == old_balance + x ); promise( invariant() ); } void withdraw(float x) { require( x <= _balance ); // check precondition hold(); // to save the old state _balance -= x; promise( balance() == old_balance - x ); promise( invariant() ); } virtual bool invariant() { return balance() >= 0; } protected: float _balance; float old_balance; // additional variable virtual void hold() { old_balance = _balance; } };

slide: The realization of the $account$ contract


Refining a contract -- state responsibilities and obligations

  • invariance -- respect the invariants of the base class
  • methods -- services may be added or refined

Refining a method -- like improving a business contract


  class C : public P {
  	virtual void m();
  	}
  

  • pre(m_C) >= pre(m_P)

  • post(m_C) <= post(m_P)


slide: Contracts and inheritance



  class credit_account : public account { 
credit_account
public: credit_account(float x) { _maxcredit = x; _credit = 0; } float balance() { return _balance + _credit; } float credit(float x) { require( x + _credit <= _maxcredit ); hold(); _credit += x; promise( _credit = old_credit + x ); promise( _balance = old_balance); promise( invariant() ); } void reduce(float x) { require( 0 <= x && x <= _credit ); hold(); _credit -= x; promise( _credit = old_credit - x ); promise( _balance = old_balance ); promise( invariant() ); } bool invariant() { return _credit <= _maxcredit && account::invariant(); } protected: float _maxcredit, _credit; float old_credit; void hold() { old_credit = _credit; account::hold(); } };

slide: Refining the account contract


Assertions -- side-effect free

contracts


  • require -- test on delivery
  • promise -- test during development

Object invariance -- exceptions

  • invariant -- verify when needed

Global properties -- requirements

  • interaction protocols -- formal specification

slide: Runtime consistency checking


Formal specification -- contracts

  • type specification -- local properties
  • relational specification -- structural properties, type relations
  • functional specification -- requirements

Verification -- as a design methodology

  • reasoning about program specification/code

Runtime consistency -- invariance

  • behavioral types specify test cases
  • invariants and assertions monitor consistency

slide: Formal specification and verification


Development methods

1



slide: Section 3.1: Development methods


Identifying objects

2



slide: Section 3.2: Identifying objects


Contracts

3



slide: Section 3.3: Contracts


Towards a formal approach

4



slide: Section 3.4: Towards a formal approach

  1. Describe the Fusion method. How does Fusion compare with other methods of OO analysis and design?
  2. Give an outline of the steps required in object-oriented design. What heuristics can you think of for identifying objects?
  3. What criteria may be used to eliminate spurious classes from an initial object model?
  4. Explain the methods of CRC cards. Give an example.
  5. Explain how you may characterize the behavior of an object by means of a contract.
  6. What benefits may design by contract have for system developers? And for users?
  7. Give a detailed account of the issues that arise in refining a contract.
  8. How may contracts be employed to test object behavior?
  9. Discuss how a formal approach may contribute to OO software development.

 [Fowler97] is not only a good introduction to UML, but contains also many useful insights on the process of object-oriented development. Additionally,  [Fowler97a] may be read as a source on analysis patterns, which are reusable elements of analysis and design. For more information on Fusion, consult  [Fusion]. As earlier references on object-oriented methods, I recommend  [Booch94],  [WWW90] and  [Rum91]. Also worthwhile are  [Henderson93] and  [Champeaux93]. An overview and comparative study of design representation methods is given in  [Webster].  [Meyer97] is the ultimate reference on contracts. A more comprehensive article on design by contract is  [Meyer92].