Вы находитесь на странице: 1из 31

ISYS6506

Information Systems
Analysis and Design

Week 7/Session 11
Class and Method Design
Learning Outcomes
• LO 4: Model the requirements design
References
• ALAN DENNIS, BARBARA HALEY WIXOM,
DAVID TEGARDEN. (2015). SYSTEM ANALYSIS
AND DESIGN: An Object-Oriented Approach
with UML. 5th Edition. Wiley. ISBN:
9781118804674.
– Chapter 8
Sub Topics
• Review of the Basic Characteristics of Object
Orientation
• Design Criteria
• Object Design Activities
• Constraints and Contracts
• Method Specification
• Verifying and Validating Class and Method
Design
REVIEW OF THE BASIC
CHARACTERISTICS OF OBJECT
ORIENTATION
Classes, Objects,
Methods, and Messages
Classes Templates that we use to define both the data

and processes that each object contains.

Objects Objects are instances of classes. Each object has


attributes that describe data about the object.

Methods are used to implement the operations


Methods

that specified the behavior of the objects.

To get an object to perform a method, a message is sent to the object. A


Messages message is essentially a function or procedure call from one object to


another object.
Encapsulation and
Information Hiding

Encapsu ●
… is the mechanism that
combines the processes and
lation data into a single object.

Informati … suggests that only the information required


to use an object be available outside the


object; that is, information hiding is related to
on Hiding the visibility of the methods and attribute
Polymorphism and
Dynamic Building

Polymor … means having the ability to take several forms.


By supporting polymorphism, object-oriented


systems can send the same message to a set of

phism objects, which can be interpreted differently by


different classes of objects.

Dynamic ●
… refers to the ability of object-
oriented system to defer the data
Building typing of objects to run time.
Inheritance

Inherit … allow developers to define classes


incrementally by reusing classes defined


previously as the basis for new classes.

ance

Subclasses inherit the attributes and
methods from the superclasses above them.
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.
• Two types of coupling:
– Interaction
• Deals with the coupling among methods and objects through message
passing.
– Inheritance
• Deals with how tightly coupled the classes are in an inheritance
hierarchy.
Types of Interaction
Coupling

Source: Dennis, 2015, pg. 288


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.
• Three general types of cohesion:
– Method cohesion, addresses the cohesion within an individual
method, should do one and only one thing.
– Class cohesion, is the level of cohesion among the attributes
and methods of a class, should represent only one thing.
– Generalization/Specialization, addresses the sensibility of the
inheritance hierarchy.
Types of Method
Cohesion

Source:
Dennis, 2015, pg. 290
Types of Class Cohesion

Source: Dennis, 2015, pg. 291


Connascence
• Connascence generalizes the ideas of cohesion and coupling, it
combines them with the arguments for encapsulation.

Source: Dennis, 2015, pg. 293


OBJECT DESIGN ACTIVITIES
Adding Specifications
Ensure
Decide onthat
Finalize the classes
thesignature
the visibility on
of every
the problem-domain
method (name of the method,layer
(hidden or visible) of the
are both necessary
parameters or arg umentsand
that
attributes
sufficient toand
must be passed, a ndmethods
solve type
theof value
thateach
in class.
will return)
underlying in every class.
problem.

Defi
ne
any
con
stra
ints
(pre
con
diti
ons,
pos
tco
ndi
tion
s,
inva
rian
ts)
that
mus
t be
pre
serv
ed
by
the
obj
ects
.
Identifying Opportunities
for Reuse
… is composed of a set of implemented classes

Framework that can be used as a basis for implementing an


application.

… is similar to a framework. In fact,


Class Library framework may be built using a class library.

… is a self-contained, encapsulated piece of


Component software that can be plugged into a system to


provide a specific set of required functionalities.
Restructuring the Design
Factoring?

Normalization?

Inheritance Relationship?
Optimizing the Design
Review the access paths between objects.

Review each other attribute of each class.

Review the direct and indirect fan-out of each method.

Look at the execution order of the statements in often-used methods.

Avoid recomputation by creating a derived attributes (or active value).

Deals with objects that participate in a one-to-one association.


CONSTRAINTS AND CONTRACTS
Types of Constraint

Preconditions


… is a constraint that must be met for a method to execute.

Postconditions


… is a constraint that must be met after the method executes, or the effect of the method execution must be undone.

Invariants


… model constrains that must be always be true for all instances of a class.
Contracts
• … formalizes the interactions between the client
and server objects, where a client (consumer)
objects is an instance of a class that sends a
message to a server (supplier) object that
executes one of its methods in response to the
request.

• Contracts are modeled on the legal notion of a


contract.
Sample Contract Form

Source:
Dennis, 2015, pg. 309
METHOD SPECIFICATION
Method Specification
Form

Source: Dennis, 2015, pg. 315


Method Specification
Form (Cont.)

Source:
Dennis, 2015, pg. 315
VERIFYING AND VALIDATING CLASS
AND METHOD DESIGN
Verifying and Validating
Class and Method Design
Recommend that a walkthrough of all of the evolved problem domain representations be performed.

All constraints, contracts, and method specifications must be tested.


Thank You

Вам также может понравиться