Object Oriented Design Using UML - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Object Oriented Design Using UML

Description:

lookup entry, supply password, insert new entry, delete existing entry, modify ... employees, set telephone number field, get telephone number field, compare entries. ... – PowerPoint PPT presentation

Number of Views:71
Avg rating:3.0/5.0
Slides: 27
Provided by: pku67
Category:

less

Transcript and Presenter's Notes

Title: Object Oriented Design Using UML


1
Object Oriented Design Using UML
  • IntroductionUML and Modeling
  • Objects and Classes
  • Finding Classes
  • Relationships
  • Operation and Atributes
  • Class Diagram and Template Codes

2
IntroductionWhat Is the UML?
  • The Unified Modeling Language (UML) is a language
    for
  • Specifying
  • Visualizing
  • Constructing
  • Documenting
  • the artifacts of a software-intensive system

3
Introduction Why Modeling?
A Language Is Not Enough
Team-Based Development
Modeling Language
Process
4
Object 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

5
Class and Objects
  • Difference between class and objects
  • Class has 3 compartments
  • Name
  • Attribute
  • Operation

Class with attributes
Objects with values
6
Attributes
  • 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

7
Operations
  • 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

8
Object 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

9
Objects and Class
  • Class Notation in UML

Example student class
10
Finding 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.

11
Finding 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.
13
Relationships Object Interactions
  • Association
  • Multiplicity
  • Role
  • Qualified association
  • Association as a class
  • Aggregation
  • Generalization/Inheritance

14
Relationships/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.
15
Association Multiplicity
  • Specifies how many instances of one class may
    relate to a single instance of an associated
    class.
  • i.e.

16
Association 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.

17
AssociationQualified 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.

18
Relationships/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

19
Relationships/Links Aggregation
  • part-whole

whole
part
20
Relationships/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
21
Relationships/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.

22
Aggregation 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

23
Class Diagram Student Registration
  • Show static modeling elements i.e classes and
    their relationships.

24
Template 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()
25
Template Code Student Registration
  • class PostGraduateStudent extends Student
  • boolean workingExperience
  • void getThesis()
  • class DiplomaStudent extends Student
  • boolean practicalTraining
  • void getTraining()

26
Template 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)
Write a Comment
User Comments (0)
About PowerShow.com