Identify OO Classes

advertisement
Identify Domain Classes
Brain Storming Technique
Noun Method Technique
1
Revision:

Study-guide:


P 6 – 13, O-O Principles
Exercises p13
2
Background:



During the analysis phase, the problem
domain objects are modeled using the class
diagram, and
The interaction is modeled using the
sequence diagram
During the design phase, interface objects
are added to provide an interface for the user
to use to interact with the problem domain
objects
3
Background:



A UML class diagram is used to model the
data structure
Information is in fact what data modeling is
trying to capture
You need to realize there is a difference
between


transient object (like user interface objects), and
persistent objects (problem domain objects).
Systems Analysis and Design in a Changing World, 6th Edition
4
Introduction

Classes are templates for defining




the characteristics and
Operations of an OBJECT
A class is a specification that an object
implements
A class supports the OO principles of




Abstraction
Encapsulation
Polymorphism
Reusability
5
6
Classes:


Classes provide a template, or blueprint that
defines the variables and the methods
common to all objects that are based on it
Classes specify



Knowledge/attributes: they know things
Behavior/methods: they do things
NOTE: Domain models we do not specify
methods
7
Attributes


They define the characteristics of the class
that, COLLECTIVELY capture ALL the
information about the class
Looking for attributes:


Descriptive attributes provide intrinsic information
about the class
Information about enrollment, test scores, and
education goals would be intrinsic to STUDENT
and not to MOTORCAR
8
Identifying classes





Too many classes, results in poor performance,
unnecessary complexity and increased maintenance
Too few classes increases coupling, and make them
large and unwieldy
Strive for cohesiveness: reduces coupling, enable
extensibility and maintainability
Discover the NOUNS and noun PHRASES
Especially id characteristics: an ORDER NUMBER
has no characteristics, it can only take on values,
and most probably helps describing an ORDER
9
ID classes



Another method is to identify the business
rules
These business rules describe the operations
of a business
It also has the advantage of discovering the
association/relationship between classes
10
Classes




Either method will yield a list of CANDIDATE
classes
The list won’t be complete nor will every class
be appropriate
The goal is to identify the major or obvious
classes
Once the list has been created, analyze the
candidate classes for associations with other
classes
11
Classes cont.




How do they relate to each other and to the
business process?
Why keep a class? Is it redundant or
unnecessary?
Keep it only if it plays a collaborating role.
When a class is kept, move it to the design
classes
12
Example: Design classes
Candidate Classes
Design Classes
Student
Student
Teacher
Professor
Class
Class
Subject
Course
Grades
Takes Values: 1-100
Tests
Takes Values: 1-100
13
Design classes: Call Meal
Candidate Classes
Design Classes
14
Associations





Classes in an application system do not exist in
vacuum
Classes are associated with, or related to, other
classes
Start with the core class: the class that interacts
with as many other classes as possible
An association is usually modeled using a solid
line that connects two classes.
Associations also have roles: Each class in an
association has a role that describes its meaning
in the relationship.
15
multiplicity


An indication of how many objects participate
in the relationship
Thy are conditional or unconditional:




Objects of class A may know about many objects
of class B
Objects of class A may know about a single object
of class B
Objects of class A must know about a single object
of class B
Objects of class A must know at least one object of
class B
16
17
Exercise



A Professor may teaches many Students
A Student is taught by at least one Professor
Open MS Visio  UML and draw the above
association
18
Other characteristics




Association
Composition
Aggregation
Generalization/specialization
19
Further definitions
Class
Attributes
Association
Multiplicity
20
Download