Class and Method Design PDF
Document Details
Uploaded by AmusingGrowth
BINUS University
Tags
Summary
This is a lecture presentation on class and method design as part of program design methods. It covers various design criteria, such as coupling and cohesion as well as constraints and contracts. The presentation is a helpful resource for gaining insights and understanding program design methods within an object-oriented context.
Full Transcript
Course : Program Design Methods Class and Method Design Session 13 Sub Topics Design Criteria Object Design Activities Constraints and Contract Method Specification Verifying and Validating Acknowledgement These slides hav...
Course : Program Design Methods Class and Method Design Session 13 Sub Topics Design Criteria Object Design Activities Constraints and Contract Method Specification Verifying and Validating Acknowledgement These slides have been adapted from: Alan Dennis, Barbara Haley Wixom, David Tegarden (2015). Systems Analysis and Design_ An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 Chapter 8 Learning Objectives At the end of this lecture, students are able to: LO3: To analyze the requirement of a system LO4: To design class and its methods Introduction Design Criteria “A good design is one that balances trade-off s to minimize the total cost of the system over its entire lifetime.” These criteria include coupling, cohesion, and connascence A. Dennis et al.,(2015). Systems Analysis and Design An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 Design Criteria Coupling Coupling refers to how interdependent or interrelated the modules (classes, objects, and methods) are in a system The higher the interdependency, the more likely changes in part of a design can cause changes to be required in other parts of the design. A. Dennis et al.,(2015). Systems Analysis and Design An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 Design Criteria Type of Coupling A. Dennis et al.,(2015). Systems Analysis and Design An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 Design Criteria Cohesion Cohesion refers to how single-minded a module (class, object, or method) is within a system. A class or object should represent only one thing, and a method should solve only a single task A. Dennis et al.,(2015). Systems Analysis and Design An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 Balancing Functional and Structural Models Type of Cohesion A. Dennis et al.,(2015). Systems Analysis and Design An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 Design Criteria Connascence Definition (Webster Dictionary): The common birth of two or more at the same time; production of two or more together. Connascence generalizes the ideas of cohesion and coupling, and it combines them with the arguments for encapsulation. 3 levels of encapsulation. Level-0 encapsulation refers to the amount of encapsulation realized in an individual line of code Level-1 encapsulation is the level of encapsulation attained by combining lines of code into a method Level-2 encapsulation is achieved by creating classes that contain both methods and attributes A. Dennis et al.,(2015). Systems Analysis and Design An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 Design Criteria Type of Connascence A. Dennis et al.,(2015). Systems Analysis and Design An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 Constraints and Contracts Contracts are modeled on the legal notion of a contract, where both parties, client and server objects, have obligations and rights A contract is a set of constraints and guarantees A. Dennis et al.,(2015). Systems Analysis and Design An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 Constraints and Contracts Types of Constraints precondition is a constraint that must be met for a method to execute postcondition is a constraint that must be met aft er the method executes A. Dennis et al.,(2015). Systems Analysis and Design An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 Method Specification Methods on the CRC cards, class diagram, and contracts are described using method specifications Typical method specification forms contain four components general information Events message passing Algorithm specification – usually represented in an activity diagram A. Dennis et al.,(2015). Systems Analysis and Design An Object-Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4 References Alan Dennis, Barbara Haley Wixom, David Tegarden (2015). Systems Analysis and Design_ An Object- Oriented Approach with UML, 5th ed. ISBN: 978-1-118-80467-4