3-1 encapsulation and connascence encapsulation and connascence are the two fundamental properties...

15
3- 3-1 Encapsulation and Co Encapsulation and Co nnascence nnascence Encapsulation and connascen Encapsulation and connascen ce are the two fundamental p ce are the two fundamental p roperties of object-oriented roperties of object-oriented systems systems Present in both traditional Present in both traditional and object-oriented systems and object-oriented systems Encapsulation Structure Encapsulation Structure connascence connascence

Upload: candace-wells

Post on 14-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-11

Encapsulation and ConnaEncapsulation and Connascencescence

• Encapsulation and connascence aEncapsulation and connascence are the two fundamental properties re the two fundamental properties of object-oriented systemsof object-oriented systems

• Present in both traditional and objPresent in both traditional and object-oriented systemsect-oriented systems

• Encapsulation StructureEncapsulation Structure

• connascenceconnascence

Page 2: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-22

EncapsulationEncapsulation• Original MeaningOriginal Meaning– grouping of related ideas into one unit– can be referred to by a single name

• Existing Concept in Software DesignExisting Concept in Software Design– repeating pattern in programs– subroutine

• Object-Oriented EncapsulationObject-Oriented Encapsulation– packaging of operations and attributes– become an object type– access attributes only via object

interface

Page 3: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-33

Encapsulation StructureEncapsulation Structure• SubroutineSubroutine– introduce encapsulation to software– encapsulate lines of code into a

structure one level higher

• Levels of EncapsulationLevels of Encapsulation– Level 0 - raw code (no encapsulation)– Level 1 - subroutine– Level 2 - object– Higher Levels - grouped classes

• Concept of Classes improves Concept of Classes improves reusabilityreusability

Page 4: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-44

Encapsulation by Encapsulation by Grouping ClassesGrouping 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

Page 5: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-55

Design Criteria for Design Criteria for EncapsulationEncapsulation

• Traditional Structured Design vs. Object-Traditional Structured Design vs. Object-Oriented DesignOriented 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

Page 6: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-66

Structured Design CriteriaStructured Design Criteria

TO

From

Level-0(line of code)

Level-1(procedure)

Level-0(line of code)

Structuredprogramming

Fan-out

Level-1(procedure)

Cohesion Coupling

Page 7: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-77

O-O Design CriteriaO-O Design Criteria

ToFrom

Level-0(line of code)

Level-1(procedure)

Level-2(class)

Level-0(line of code)

Structuredprogramming

Messagefan-out

Level-1(procedure)

Cohesion Coupling

Level-2(class)

Classcohesion

Classcoupling

Page 8: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-88

ConnascenceConnascence• 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 BoundariConnascence and Encapsulation Boundarieses

• Connascence and MaintainabilityConnascence and Maintainability

• Connascence Abuses in O-O SystemsConnascence Abuses in O-O Systems

Page 9: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-99

Connascence in SoftwareConnascence in Software

• Connascence between software elemenConnascence between software elements A and Bts A and B– change in A requires B to be changed– A and B need to be changed together

• Software element needn’t communicatiSoftware element needn’t communication in order to connascenton in order to connascent

• Connascence can be directional or nonConnascence can be directional or nondirectionaldirectional

Page 10: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-1010

Static ConnascenceStatic 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

Page 11: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-1111

Dynamic ConnascenceDynamic Connascence• Based on the execution pattern of the runniBased on the execution pattern of the runni

ng code (objects)ng 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

Page 12: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-1212

ContranascenceContranascence

• Connascence of DifferenceConnascence of Difference

• Negative ConnascenceNegative Connascence

• Mostly Contranascence of NamesMostly Contranascence of Names

• Specially Important for Multiple InherSpecially Important for Multiple Inheritanceitance

Page 13: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-1313

Connascence and EncapsuConnascence and Encapsulation Boundarieslation Boundaries

• Object orientation eliminates some of thObject orientation eliminates some of the connascence in traditional modular sye connascence in traditional modular systemsstems

• Encapsulatio is a check on connascencEncapsulatio is a check on connascence and contranascencee and contranascence

Page 14: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-1414

Connascence and MaintaiConnascence and Maintainabilitynability

• Offers guidelines for improving system Offers guidelines for improving system maintainabilitymaintainability

• Minimize overall connascence and contMinimize overall connascence and contranascence => encapsulationranascence => encapsulation

• Minimize any remaining connascence tMinimize any remaining connascence that crosses encapsulation boundarieshat crosses encapsulation boundaries

• Mazimize connascence within encapsuMazimize connascence within encapsulation boundarieslation boundaries

Page 15: 3-1 Encapsulation and Connascence Encapsulation and connascence are the two fundamental properties of object-oriented systems Encapsulation and connascence

3-3-1515

Connascence Abuses in Connascence Abuses in Object-Oriented SystemsObject-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 implementatiRelying on accidents of implementationon– ex. connascence of algorithm