100 likes | 216 Views
INFS 6225 – Object-Oriented Systems Analysis & Design. Chapter 8: Class & Method Design. Class & Method Design. Criteria, activities, & techniques used to design classes & methods Part of Design Phase where work is actually accomplished
E N D
INFS 6225 – Object-Oriented Systems Analysis & Design Chapter 8: Class & Method Design
Class & Method Design • Criteria, activities, & techniques used to design classes & methods • Part of Design Phase where work is actually accomplished • Refinement of UML models to create the mostefficient system possible that still meets the users’ requirements • The steps justbefore the actual coding of the system
Review of Terms • Object – basic building block of a system; instances of classes • Class – defines both data & processes that each object contains • Attributes – describe data about the object • Methods – specify processes that objects can perform • Message – procedural call from one object to another
More Terms • Inheritance – superior classes pass attributes & methods to subordinate classes • Encapsulation – combining processes & data into a single object • Information Hiding – only information required to use an object should be available outside of an object • Polymorphism – same message is interpreted differently by different objects • Dynamic binding – interpretation of message by an object takes place at run time
New Terms • Cohesion – how specific a module is within a system (i.e., a class or object should represent only one thing) • Coupling – level of interdependence among modules (classes, objects, & methods) in a system • The higher the degree of coupling, the more likely that changes in part of a system will require changes in other parts • Connascence – two modules are so intertwined that a change in one requires a change in the other • Ideally, a system should have high Cohesion and low (i.e., loose) Coupling
Opportunities for Reuse • Class Library • Set of implemented classes that are designed for reuse • Pre-built “template” classes with Attributes and Methods already defined • Can be utilized using Inheritance • Support Foundation Layer • Component • Self-contained piece of software that can be “plugged” into a system • Simplify development of objects on Problem Domain & Human-Computer Interaction Layers
Optimizing the Design • Shorten/simplify paths between objects • Move attributes to provide more direct access • Reduce the number of messages (Fan-out) sent by an object • Reorder execution of statements • Cache (temporarily save) computational results
Constraints & Contracts • Contract • formalizes the interactions between client and server objects • Document the message passing between objects • Contain information necessary for programmer to understand method • Contracts may contain: • Pre-conditions – constraints that must be met for a method to execute • Post-conditions – constraints that must be met after the method executes (or method is undone)
Contract Example Method Name: Class Name: ID: Clients (Consumers): Associated Use Cases: Description of Responsibilities: Arguments Received: Type of Value Returned: Pre-Conditions: Post-Conditions:
Method Specification • Method Specifications – written documents that include explicit instructions on how to write the code to implement a method • No standard syntax for Method Specification • Written in Structured English – short sentences • 4 Components: • General Information about Method • Events – items that trigger method • Message Passing – what is being passed, and returned • Algorithm Specification (calculations, formula, etc.)