INFS 6225 – Object-Oriented Systems Analysis & Design
description
Transcript of INFS 6225 – Object-Oriented Systems Analysis & Design
INFS 6225 – Object-Oriented INFS 6225 – Object-Oriented Systems Analysis & DesignSystems Analysis & Design
Chapter 8: Chapter 8: Class & Method DesignClass & Method Design
Class & Method DesignClass & Method Design
Criteria, activities, & techniques used to design classes & methodsCriteria, activities, & techniques used to design classes & methods
Part of Design Phase where work is actually accomplishedPart of Design Phase where work is actually accomplished
Refinement of UML models to create the Refinement of UML models to create the mostmost efficientefficient system system possible that still meets the users’ requirementspossible that still meets the users’ requirements
The steps The steps justjust beforebefore the actual coding of the system the actual coding of the system
Review of TermsReview of Terms
ObjectObject – basic building block of a system; instances of classes – basic building block of a system; instances of classes
ClassClass – defines both data & processes that each object contains – defines both data & processes that each object contains
AttributesAttributes – describe data about the object – describe data about the object
MethodsMethods – specify processes that objects can perform – specify processes that objects can perform
MessageMessage – procedural call from one object to another – procedural call from one object to another
More TermsMore Terms
InheritanceInheritance – superior classes pass attributes & methods to – superior classes pass attributes & methods to subordinate classessubordinate classes
EncapsulationEncapsulation – combining processes & data into a single object – combining processes & data into a single object
Information HidingInformation Hiding – only information required to use an object – only information required to use an object should be available outside of an objectshould be available outside of an object
PolymorphismPolymorphism – same message is interpreted differently by different – same message is interpreted differently by different objectsobjects
Dynamic bindingDynamic binding – interpretation of message by an object takes – interpretation of message by an object takes place at run timeplace at run time
New TermsNew Terms
CohesionCohesion – how specific a module is within a system (i.e., – how specific a module is within a system (i.e., a class or object should represent only one thing)a class or object should represent only one thing)
CouplingCoupling – level of interdependence among modules – level of interdependence among modules (classes, objects, & methods) in a system(classes, objects, & methods) in a system
The higher the degree of coupling, the more likely that changes in The higher the degree of coupling, the more likely that changes in part of a system will require changes in other partspart of a system will require changes in other parts
ConnascenceConnascence – two modules are – two modules are soso intertwined that a change in intertwined that a change in one requires a change in the otherone requires a change in the other
Ideally, a system should have Ideally, a system should have highhigh Cohesion Cohesion and and lowlow (i.e., (i.e., loose)loose) Coupling Coupling
Opportunities for ReuseOpportunities for Reuse
Class LibraryClass Library Set of implemented classes that are designed for reuseSet of implemented classes that are designed for reuse Pre-built “template” classes with Attributes and Methods already definedPre-built “template” classes with Attributes and Methods already defined Can be utilized using Can be utilized using InheritanceInheritance Support Foundation LayerSupport Foundation Layer
ComponentComponent Self-contained piece of software that can be “plugged” into a systemSelf-contained piece of software that can be “plugged” into a system Simplify development of objects on Problem Domain & Human-Simplify development of objects on Problem Domain & Human-
Computer Interaction LayersComputer Interaction Layers
Optimizing the DesignOptimizing the Design
1.1. Shorten/simplify paths between objectsShorten/simplify paths between objects
2.2. Move attributes to provide more direct accessMove attributes to provide more direct access
3.3. Reduce the number of messages (Fan-out) sent by an Reduce the number of messages (Fan-out) sent by an objectobject
4.4. Reorder execution of statementsReorder execution of statements
5.5. Cache (temporarily save) computational resultsCache (temporarily save) computational results
Constraints & ContractsConstraints & Contracts
ContractContract formalizes the interactions between client and server objectsformalizes the interactions between client and server objects Document the message passing between objectsDocument the message passing between objects Contain information necessary for programmer to understand Contain information necessary for programmer to understand
methodmethod
Contracts may contain:Contracts may contain: Pre-conditionsPre-conditions – constraints that must be met for a method to – constraints that must be met for a method to
executeexecute Post-conditionsPost-conditions – constraints that must be met after the method – constraints that must be met after the method
executes (or method is undone)executes (or method is undone)
Contract ExampleContract 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 SpecificationMethod Specification
Method Specifications – written documents that include explicit Method Specifications – written documents that include explicit instructions on how to write the code to implement a methodinstructions on how to write the code to implement a method
No standard syntax for Method SpecificationNo standard syntax for Method Specification
Written in Written in Structured EnglishStructured English – short sentences – short sentences
4 Components:4 Components:1.1. General InformationGeneral Information about Method about Method2.2. EventsEvents – items that – items that triggertrigger method method3.3. Message Passing Message Passing – what is being passed, and returned– what is being passed, and returned4.4. Algorithm Specification Algorithm Specification (calculations, formula, etc.)(calculations, formula, etc.)