01 / 55Principles of Object-Oriented Software Development
1 / 17
Download Presentation
Principles of Object-Oriented Software Development
An Image/Link below is provided (as is) to download presentation
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.Content is provided to you AS IS for your information and personal use only.Download presentation by click this link.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.During download, if you can't get a presentation, the file might be deleted by the publisher.
Modeling reality- vernacular • requirements -- use cases • analysis -- domain concepts • design -- system architecture • implementation – languagesupport Design model-- system oriented provides a justification of the architecture
Dimensions of modeling OMT • object model -- decomposition into objects • dynamic model -- intra-object state changes • functional model -- object interaction (data-flow) Model of control procedure-driven, event-driven, concurrent
Model criteria • unambiguous -- single meaning • abstract -- no unnecessary detail • consistent -- absence of conflict formal approach
Analysis Fusion • Object Model -- concepts and relations • LifeCycle Model -- sequences of operations • Operation Model -- semantics of system operations
Design data dictionary • Object Interaction Graph -- functional dependencies • Visibility Graphs -- communication structure • Class Descriptions -- attributes and methods • Inheritance Graphs -- subtype refinement
Implementation validation • System Lifecycle -- state machines • Class Descriptions -- coding, performance
Modeling heuristics Objects -- crisp entities object = an entity that suffers and requires actions The method: [1] Identify the objects and their attributes [2] Identify operations suffered and required [3,4] Establish visibility/interface
Heuristics model of reality -- balance nouns (objects) and verbs (operations) Associations directed action -- drives, instructs communication -- talks-to, tells, instructs ownership -- has, part-of resemblance -- like, is-a others -- works-for, married-to
Candidate classes ATM • account -- customer's account in the banks database • atm -- performs financial services for a customer • cardreader -- reads and validates a customer's card • cashdispenser -- gives cash to the customer • screen -- presents text and visual information • keypad -- the keys a customer can press • pin -- the authorization code • transaction -- performs financial services and updates the database
Object-Oriented Thinking CRC • Immerse the reader in the object-ness of the material • Give up global knowledge of control. • Rely on the local knowledge of objects. OO-Design with CRC cards Class, Responsibility, Collaborators.
Object roles and interaction • actor -- operates (suffers no operations) • server -- suffers operations • agent -- suffers and operates ( actor & server)
System development • violated pre-condition -- bug in client • violated post-condition -- bug in supplier A pre-condition limits the cases that a supplier must handle!
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; } };
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) weaken pre-condition post( m_C ) <= post(m_P) strengthen post-condition
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
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