COMP 325 Lecture 6: Modules and Objects
major resources: Object-Oriented and Classical Software Engineering 6ed,
Schach 2005, Object-Oriented Software Engineering, Schach 2008.
[ previous
| schedule
| next
]
Introduction
- need for modular rather than monolithic structure
- top-down design
- affect of modularity on quality attributes
- evolution from module to object
Definition of Module
- matter of debate
- easy to define in language-dependent or paradigm-dependent way
- more difficult to define in general way
- Schach likes Yourdon definition: lexically contiguous sequence of program statements, bounded by
boundary elements, having an aggregate identifier
- Yourdon definition general enough to cover functions and procedures in procedural paradigm (Pascal, C)
in addition to classes and methods in OO paradigm (C++, Java)
- Does Yourdon definition cover functional paradigm? (Lisp, Scheme) Logic paradigm? (Prolog)
Definition of Object
- not particularly controversial but hard to define concisely
- instance of a class (begs the question)
- something that has attributes, behaviors, identity, encapsulation and state
- what do all those terms mean? Illustrate with example
Cohesion
- a measure of how well a module "fits together"
- a module should implement a single logical entity or function
- cohesion is desirable : changes are localized in a single cohesive component
- various levels of cohesion have been identified
- Coincidental cohesion (weak): Component parts are simply bundled together without rhythm or reason
- Logical cohesion (weak): Components which perform similar functions are grouped
- Temporal cohesion (weak): Components which are activated at the same time are grouped
- Procedural cohesion (weak): Components that make up a single control sequence are grouped
- Communicational cohesion (medium): components that operate on the same data are grouped
- Functional cohesion (strong): module performs one function and each operation is necessary
- Informational (Object) cohesion (strong): Each operation in module has separate identity and operates independently on common data structure
Coupling
- A measure of the strength of the inter-connections between system components
- Loose coupling desirable: component changes are unlikely to affect other components
- various degrees of coupling have been identified
- Content coupling (tight): one directly references content of other
- Common coupling (tight): shared variables or control information
- Control coupling (relaxed fit): control information shared via parameters "with intent"
- Stamp coupling (relaxed fit): data shared via parameter but only part of parameter needed
- Data coupling (loose): data shared via parameter and all parts of parameter needed
Cohesion and coupling affect quality
- in general, the stronger the cohesion the higher the quality
- in general, the looser the coupling the higher the quality
- consider corrective maintainability
- consider adaptive maintainability
- consider perfective maintainability
- consider reusability
- consider these quality measures: robustness, understandability, portability, performance
- what about quality measures such as usability and learnability?
Encapsulation
- gathering all aspects of modeled entity into one module (object)
- OO language is not required to achieve this
- neither is this guaranteed by use of OO language
- how do you achieve this using OO language?
- what are implications for cohesion and coupling (and thus quality)?
Information Hiding
- module hides implementation details of its encapsulated properties from other modules
- OO language is not required to achieve this (e.g. Ada package)
- neither is this guaranteed by use of OO language
- how do you achieve this using OO language?
- what are implications for cohesion and coupling (and thus quality)?
Object Oriented Paradigm
- paradigm (PAIR-a-dime): a pattern or model (Oxford dictionary), theoretical framework (science), conceptual framework for thinking about programs (Sanderson)
- associations
- aggregation
- inheritance
- polymorphism
- what are implications of each for cohesion and coupling (and thus quality)?
[ COMP 325
| Peter Sanderson
| Math Sciences server
| Math Sciences home page
| Otterbein
]
Last updated:
Peter Sanderson (PSanderson@otterbein.edu)