Download presentation
Presentation is loading. Please wait.
Published byCandace Wells Modified over 9 years ago
1
3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence are the two fundamental properties of object-oriented systems Present in both traditional and object-oriented systems Present in both traditional and object-oriented systems Encapsulation Structure Encapsulation Structure connascence connascence
2
3-2Encapsulation Original Meaning Original Meaning – grouping of related ideas into one unit – can be referred to by a single name Existing Concept in Software Design Existing Concept in Software Design – repeating pattern in programs – subroutine Object-Oriented Encapsulation Object-Oriented Encapsulation – packaging of operations and attributes – become an object type – access attributes only via object interface
3
3-3 Encapsulation Structure Subroutine Subroutine – introduce encapsulation to software – encapsulate lines of code into a structure one level higher Levels of Encapsulation Levels of Encapsulation – Level 0 - raw code (no encapsulation) – Level 1 - subroutine – Level 2 - object – Higher Levels - grouped classes Concept of Classes improves reusability Concept of Classes improves reusability
4
3-4 Encapsulation by Grouping Classes Horizontal GroupHorizontal Group –grouping by respective subject area –comprises classes from the same domain –packages Vertical GroupVertical Group –grouping by business activity –usually come from several domains –components
5
3-5 Design Criteria for Encapsulation Traditional Structured Design vs. Object- Oriented DesignTraditional Structured Design vs. Object- Oriented Design Criteria for interacting levelsCriteria for interacting levels –structured programming - line to line –fan-out - reference to other procedures –cohesion - connection within procedure –coupling - connection between procedures –class cohesion - connection within class –class coupling - connection between classes
6
3-6 Structured Design Criteria
7
3-7 O-O Design Criteria
8
3-8 Connascence Original meaning - born togetherOriginal meaning - born together Interdependence, CouplingInterdependence, Coupling Definition of Connascence in SoftwareDefinition of Connascence in Software Varieties of ConnascenceVarieties of Connascence ContranascenceContranascence Connascence and Encapsulation BoundariesConnascence and Encapsulation Boundaries Connascence and MaintainabilityConnascence and Maintainability Connascence Abuses in O-O SystemsConnascence Abuses in O-O Systems
9
3-9 Connascence in Software Connascence between software elements A and BConnascence between software elements A and B –change in A requires B to be changed –A and B need to be changed together Software element needn’t communication in order to connascentSoftware element needn’t communication in order to connascent Connascence can be directional or nondirectionalConnascence can be directional or nondirectional
10
3-10 Static Connascence Applied to the code of classesApplied to the code of classes Connascence of NameConnascence of Name –variables in procedures or in classes Connascence of Type or ClassConnascence of Type or Class –types in declaration Connascence of ConventionConnascence of Convention –same constraints for several elements Connascence of AlgorithmConnascence of Algorithm –similar to connascence of convention Connascence of PositionConnascence of Position –sequential, adjacent, argument order
11
3-11 Dynamic Connascence Based on the execution pattern of the running code (objects)Based on the execution pattern of the running code (objects) Connascence of ExecutionConnascence of Execution –dynamic equivalent of connascence of position Connascence of TimingConnascence of Timing –mostly in real-time systems Connascence of ValueConnascence of Value –arithmetic constraints Connascence of IdentityConnascence of Identity –object reference
12
3-12 Contranascence Connascence of DifferenceConnascence of Difference Negative ConnascenceNegative Connascence Mostly Contranascence of NamesMostly Contranascence of Names Specially Important for Multiple InheritanceSpecially Important for Multiple Inheritance
13
3-13 Connascence and Encapsulation Boundaries Object orientation eliminates some of the connascence in traditional modular systemsObject orientation eliminates some of the connascence in traditional modular systems Encapsulatio is a check on connascence and contranascenceEncapsulatio is a check on connascence and contranascence
14
3-14 Connascence and Maintainability Offers guidelines for improving system maintainabilityOffers guidelines for improving system maintainability Minimize overall connascence and contranascence => encapsulationMinimize overall connascence and contranascence => encapsulation Minimize any remaining connascence that crosses encapsulation boundariesMinimize any remaining connascence that crosses encapsulation boundaries Mazimize connascence within encapsulation boundariesMazimize connascence within encapsulation boundaries
15
3-15 Connascence Abuses in Object-Oriented Systems The friend function of C++The friend function of C++ –violate encapsulation boundaries Unconstrained inheritanceUnconstrained inheritance –introduce raging connascence Relying on accidents of implementationRelying on accidents of implementation –ex. connascence of algorithm
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.