Title: Object Oriented Design Using UML
1Object Oriented Design Using UML
- IntroductionUML and Modeling
- Objects and Classes
- Finding Classes
- Relationships
- Operation and Atributes
- Class Diagram and Template Codes
2IntroductionWhat Is the UML?
- The Unified Modeling Language (UML) is a language
for - Specifying
- Visualizing
- Constructing
- Documenting
-
- the artifacts of a software-intensive system
3Introduction Why Modeling?
A Language Is Not Enough
Team-Based Development
Modeling Language
Process
4Object and Class
- Class describe s a group of objects with similar
properties(attributes), common behavior(operations
), common relationships to other objects and
common semantics. - Semantics depends on purpose of application
i.e.building, machines may belong to different
classes or same classes if regarded as financial
assets. - Abstraction is achieved by grouping objects into
classes
5Class and Objects
- Difference between class and objects
- Class has 3 compartments
- Name
- Attribute
- Operation
Class with attributes
Objects with values
6Attributes
- Attributes is a data value held by the objects in
the class - Specify name, type, and optional default value
- attributeName Type Default
- Type should be elementary data type in
implementation language - Built-in data type, user-defined data type
7Operations
- Is a function
- All objects in a class share the same operations.
- Each operation name may be followed by optional
details (opreations signature) i.e. argument list
and result type - Operation(arg namearg type default)return
8Object and Class Naming Conventions
- Naming Class starts with a capital letter and
also for the second word - i.e. DegreeStudent
- Naming attributes and operations starts with a
small letter and second word starts with capital
letter - i.e. getGrade()
- No hyphenation between words
- Post-Graduate-Student
9Objects and Class
Example student class
10Finding Classes
- i) Method to find objects and their classes
- Begin with the nouns in the requirements
specification. - ii) Method to find operations
- Begin with the verbs in the requirements
specification. - Â Example Computerized Telephone Book For A
University - The telephone book should contain entries
for each person in the university
community--student, professor, and staff member.
Users of the directory can look up entries. In
addition, the administrator of the telephone book
can, after supplying a password, insert new
entries, delete existing entries, modify existing
entries, print the telephone book, and print a
listing of all students or of all faculty.
11Finding Classes
- 1. Identify the candidate classes. List the
nouns and noun phrases from the specification - Â computerized telephone book, university,
telephone book, entry, person, university
community, student, professor, staff member,
employee, user, administrator, password. - 2. Identify the candidate operations. List the
verbs from the specification. - Â lookup entry, supply password, insert new
entry, delete existing entry, modify existing
entry, print telephone book, print all students,
print all employees, set telephone number field,
get telephone number field, compare entries.
12- 3. Eliminate unnecessary and synonym classes and
operations. - Â For example, computerized telephone book,
telephone book, and directory can be combined
into a single PhoneBook class. - 4. Associate the operations with the
appropriate classes. - Â For example, associate lookup, insert,
delete, and modify entry operations with the
PhoneBook class, associate compare,
setPhoneNumber and getPhoneNumber with the Person
class, etc.
During design we should not be concerned with the
minute details of the implementation. However, it
is appropriate to consider whether there is a
"reasonable" implementation.
13Relationships Object Interactions
- Association
- Multiplicity
- Role
- Qualified association
- Association as a class
- Aggregation
- Generalization/Inheritance
14Relationships/LinksAssociation
Association between classes
Instance association
- When there is association between classes,
instances/objects of the class has association. -
Although associations are bidirectional, they do
not have to be implemented in both directions.
15Association Multiplicity
- Specifies how many instances of one class may
relate to a single instance of an associated
class. - i.e.
16Association Role
- A role name is a name that uniquely identifies
one end of an association. - Written next to the class that plays the role.
- i.e.
17AssociationQualified Association
- Can be used as a key to access data.
- One to many and many to many associations may be
qualified. - i.e.
- One lecturer teach a lot of students (1..).
Metricno is used to identify the student.
18Relationships/Links Aggregation
- Aggregation is the part-whole or a-part-of
relationship - objects representing the components are
associated with an object representing whole
components. - i.e. part- of
19Relationships/Links Aggregation
whole
part
20Relationships/Links Generalization
- is-a or a kind of relationship
- Generalization is the relationship between a
class and one or more refined versions of it. - Example
General
Refined
21Relationships/Links Generalization
- The general class is called superclass.
- Each refined version is called a subclass.
- Attributes and operations common to a group of
subclasses are attacthed to superclass. - Each subclass inherits the features of it
superclass.
22Aggregation vs Generalization
- Relates instances
- Composed of object instances that are all part of
composite object - part-whole or
- a-part-of relationship
- Relates classes
- Composed of classes that describe an object
- is-a or a kind of relationship
23Class Diagram Student Registration
- Show static modeling elements i.e classes and
their relationships. -
24Template Code Student Registration
class Student String name float CPA
float GPA String generateSlip(String
result) CPA 0.0 GPA 0.0 return
result class GraduateStudent extends
Student String scholarships float
scholarshipsAmount void getProject()
25Template Code Student Registration
- class PostGraduateStudent extends Student
- boolean workingExperience
- void getThesis()
-
-
-
- class DiplomaStudent extends Student
- boolean practicalTraining
- void getTraining()
-
-
-
26Template Code Student Registration
- class Subject
- String code
- float credit
- CoreSubject CSubject
- ElectiveSubject ESubject
- int register()
- return
-
-
- class CoreSubject
- float passingGrade
- float getGrades
-
- return
-
-
- class ElectiveSubject
- boolean seminar
-
- class Lecturer
-
-
- public static void main(String args)
-
-
-
-