PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 ©...
-
Upload
myron-rogers -
Category
Documents
-
view
229 -
download
0
Transcript of PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 ©...
![Page 1: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/1.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 1
Systems Analysis and Systems Analysis and DesignDesign
Alan Dennis, Barbara Wixom, and David Tegarden
John Wiley & Sons, Inc.
Slides by Fred Niederman
![Page 2: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/2.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 2
Copyright © 2001 John Wiley & Sons, Inc.
All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976 United States Copyright Act without the express written permission of the copyright owner is unlawful. Request for further information should be addressed to the Permissions Department, John Wiley & Sons, Inc. The purchaser may make back-up copies for his/her own use only and not for redistribution or resale. The Publisher assumes no responsibility for errors, omissions, or damages, caused by the use of these programs or from the use of the information contained herein.
![Page 3: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/3.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 3
Class and Method Design
Chapter 14
![Page 4: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/4.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 4
Key Concepts
Low-level or detailed design is critical despite libraries and componentsPre-existing classes need to be understood and organizedSome, if not all code, is generally still needed to instantiate new classes
![Page 5: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/5.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 5
Identify Opportunities for Reuse
PatternsUseful group of collaborating classes the provide a solution to a commonly occurring problem
FrameworkClasses used for application implementation
Class librariesSet of implemented classes designed for reuse
ComponentsSelf-contained encapsulated pieces of code that provide a certain functionality
![Page 6: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/6.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 6
REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION
![Page 7: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/7.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 7
ElementsClassesObjects – instance of a classAttributes – describes dataStates – describes object at specific point in time via an attributeMethods – processes to be performedMessages – used to get an object to perform a method
![Page 8: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/8.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 8
Encapsulation
Hiding the content of the object from outside viewCommunication only through object’s methods (via messages)Key to reusability
![Page 9: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/9.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 9
Example Unencapsulated
Desired Temp
Actual Temp
Occupancy
Heat FlowRegulator
temp ()
temp ()
occupied()
![Page 10: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/10.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 10
Example Encapsulated
Heat FlowRegulator
Room
Desired_TempActual_TempOccupancy
Monitor_Temp
need_heat()
Room contains the knowledge of when it needs heat
![Page 11: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/11.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 11
Polymorphism
Same message triggers different methods in different objectsDynamic binding means specific method is selected at run timeImplementation of dynamic binding is language specific
![Page 12: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/12.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 12
What does it mean?
polymorphism refers to a programming language's ability to process objects differently depending on their data type or classit is the ability to redefine methods for derived classes
![Page 13: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/13.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 13
Example
Given a base class shape, polymorphism enables the programmer to define different circumference methods for any number of derived classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the circumference method to it will return the correct results
![Page 14: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/14.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 14
More examples
Good exampleSend message ‘print document’ to laser printer or inkjet printerThe printer performs its own print operation
Bad exampleSend message ‘create order’Start the sales process or straighten up the living room?
![Page 15: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/15.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 15
Polymorphism Challenges
Need to be very careful about run time errors
Send message to an object that doesn’t understand itMake a decision for which there is no code
Need to ensure semantic consistencySame name for a method in 2 classes – does it mean the same thing?
![Page 16: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/16.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 16
Inheritance
Single inheritance -- one parent classMultiple inheritance -- multiple parent classesRedefinition and inheritance conflict
Attribute/method with same name
Most inheritance conflicts are due to poor classification
![Page 17: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/17.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 17
Additional Inheritance Conflicts
Two inherited attributes or methods have same name and semanticsTwo inherited attributes or methods have different name, but same semanticsTwo inherited attributes or methods have same name and different semantics
![Page 18: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/18.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 18
DESIGN CRITERIA
![Page 19: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/19.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 19
Good Design – Bad Design
Good design balances trade-offs to minimize total cost of a system over its lifetime (Coad and Yourdon)Criteria for assessing good design:
CouplingCohesionConnascence
![Page 20: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/20.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 20
Coupling
Interdependency among modules
More interdependency the more likely changes in one part will require changes in others
![Page 21: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/21.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 21
Two Types of Coupling
Interaction coupling through message passing
Minimize number of objects that can receive messages
Inheritance coupling of superclass and sub classes
Tighter coupling is preferred – supports a-kind-of
![Page 22: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/22.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 22
Law of Demeter – Interaction Coupling
Messages should be sent only by an object
to itself
to an object contained in an attribute of itself or a superclass
to an object that is passed as a parameter to the method
to an object that is created by the method
to an object that is stored in a global variable
![Page 23: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/23.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 23
Types of Interactive Coupling
Level Type
Good No Direct Coupling – no callsData – passes variable uses allStamp – passes object uses someControl – passes control variableCommon or Global – outside object
Bad Content or Pathological – method of one object refers to inside method of another (often illegal)
![Page 24: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/24.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 24
Good Interaction Coupling
Pass value of a variable along with the message
Object invoice could send to calculate tax the taxable amount
![Page 25: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/25.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 25
Bad Coupling
Global data area exists outside the object
Table of user preferences – global dataCan be changed by a number of objectsIe values might be changed between the end of one ‘run’ and the beginning of the next ‘run’
![Page 26: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/26.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 26
Bad Coupling continued
Sales tax percent stored in separate tableCalculate sales tax at 6% for one itemAnother object changes Sales tax percentNext items is calculated with 7% sales tax
![Page 27: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/27.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 27
Cohesion
“Single-mindedness of a module”Object should just represent one thing – a method should solve only one task
Types of cohesion:Method cohesionClass cohesionGeneralization/specialization cohesion
![Page 28: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/28.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 28
Types of Method CohesionLevel Type
Good Functional –single functionSequential –2 functions – output from
one is input to other Communicational – 2 functions that use
the same attributesProcedural – multiple functionsTemporal or Classical – multiple related
functions in timeLogical – multiple functions with choice
by control variableBad Coincidental – purpose not well defined
![Page 29: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/29.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 29
Method Cohesion Example
Good Method CohesionObject ‘calculate totals’ by keeping a running total
Bad Method CohesionUnrelated activities in the same method
Method that updates customer records, calculates loan payments,prints exception reports…
![Page 30: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/30.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 30
Types of Class Cohesion
Level Type
Good Ideal
Mixed-role
Mixed-domain
Worse Mixed-instance
![Page 31: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/31.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 31
Class Cohesion
IdealMethods and attributes all relate to the same entity (employee, student, etc.)
Mixed-RoleOne or more attributes relate to other objects on same layer
Student class contains instance of courses student is taking
![Page 32: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/32.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 32
Class Cohesion
Mixed-domainOne or more attributes relating to objects on a different layer
Data layer refers to objects on presentation layer
Mixed-instanceClass represents 2 different types of objects
Student and class enrollment (should be 2 separate classes)
![Page 33: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/33.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 33
Connascence
Generalizes the ideas of cohesion and coupling
Two modules (classes or methods) so intertwined that a change in one will likely require a change in the other
![Page 34: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/34.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 34
Types of Connascence
Type
Name
Type or Class
Convention
Algorithm
Position
![Page 35: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/35.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 35
Name Connascence
Refers to the situation where a method references an attribute“get product number” refers to attribute in ‘product’ classIf ‘product class’ changes the attribute name, the method must change
![Page 36: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/36.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 36
Type or Class Connascence
Refers to relationship between attribute and data typeFor instance, if date is chosen as the data type and that is changed, class must be changed
![Page 37: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/37.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 37
Convention Connascence
Values of attributes are assigned semantic meaning
Ie used as a code
Should the range of acceptable values of attribute change, methods must also be changed
![Page 38: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/38.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 38
Position Connascence
Refers to the order of code in the method or the order of arguments
Record must be found before being modified
Subtle differences can ariseCreating averages from subtotals versus the entire data set
![Page 39: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/39.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 39
Algorithm Connascence
Refers to dependency on an algorithmIf algorithm changes, methods must change
Change a hashing algorithm for finding recordsInsert record and find record must be changed
![Page 40: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/40.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 40
Class Constraints
A set of constraints and guaranteesWritten in natural language, structured English, pseudocode, or formal language – can be modeled in UML with OCL (Object Constraint Language)
![Page 41: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/41.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 41
Define constraints
Pre-conditionsMust be met for method to execute (ie invalid attributes)
Post conditionsMust be met after the method is executed (no invalid attributes)
InvariantsMust be true for all instances of a class (valid values of an attribute)
![Page 42: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/42.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 42
Constraints - TomorrowPreconditions
Valid value for today’s date
InvariantsDay, month, year positive numbersMonth must be between 1 and 12Day must be between 1 and 31Leap year anomalies must be correct
PostconditionsValid date for tomorrow
![Page 43: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/43.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 43
Constraint OCL Example
Date :: Tomorrow() pre: year < 9999 or (year = 9999 and month < 12) or (year = 9999 and month = 12 and day <31) post: if day@pre < 31 then day = day@pre + 1 else if month@pre < 12 then month = month@pre + 1 day = 1 else year = year@pre + 1 month = 1 day = 1 end if end if
![Page 44: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/44.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 44
Contract
Documents message passes that takes place between objectsCan be written for:
Each message sentEach message received
![Page 45: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/45.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 45
Contract Continued
DeclarativeSo programmer understands what the method is to do
Not proceduralDon’t spell out how the method is to work
![Page 46: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/46.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 46
Simple Contract Format
Method Name: Class Name: ID:
Clients (Consumers):
Associated Use Cases:
Description of Responsibilities:
Arguments Received:
Type of Value Returned:
Pre-Conditions:
Post-Conditions:
![Page 47: PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649cc95503460f949917e8/html5/thumbnails/47.jpg)
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.Slide 47
What to Remember
Class EncapsulationPolymorphismInheritance
CouplingCohesionConnascenceWhat is a good candidate for reuse