BCS 2143 - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

BCS 2143

Description:

BCS 2143 Object Oriented Design Using UML – PowerPoint PPT presentation

Number of Views:81
Avg rating:3.0/5.0
Slides: 43
Provided by: Rahiw
Category:
Tags: bcs | design | object | oriented

less

Transcript and Presenter's Notes

Title: BCS 2143


1
BCS 2143
  • Object Oriented Design Using UML

2
Objectives
  • Objects Interactions
  • Finding Classes
  • Relationship Between Classes
  • Attribute and Operation
  • Class Diagram

3
Outline
  • Name the basic components of object-oriented
    design using UML
  • Experience with significant diagram in UML
  • Experience with main part of class that consists
    of attributes and operation
  • Class Diagram association, aggregation and
    inheritance
  • Basic concepts in Sequence Diagram
  • Utilize all modeling concepts in solving problem

4
Unified Modeling Language
  • UML - standardized general-purpose modeling
    language in the field of software engineering
    using graphical notations
  • UML Diagrams
  • Use Case Diagram
  • Class Diagram
  • Interaction Diagram
  • Component Diagram
  • Etc.

5
UML 2.0
Emphasizes the dynamic behavior of the system by
showing collaborations among objects and changes
to the internal states of objects
Emphasizes the static structure of the system
using objects, attributes, operations and
relationships
UML 2.0 has 13 types of diagrams divided into
three categories. Six diagram types represent the
structure application, seven represent general
types of behavior, including four that represent
different aspects of interactions.
6
Use Case Diagram
  • System behavior how the system act and react
    towards their environment.
  • Consists of
  • Actor represent environment of system
  • Use case represent function of system

7
Example of Use Case Diagram for ATM Machine
Customer
Make transaction
Manage bank transaction
Bank Clerk
Bank
Produce report
ATM Maintainer
Maintain ATM Machine
8
Class Diagram
  • Diagram that consists of several classes or
    objects.
  • Object
  • represent specific entity in term of physical and
    conceptual
  • have the behaviors, characteristics and identity
  • Class
  • Represent a group of object that have the similar
    attribute, behavior and relationship among the
    others

9
Example of Class Diagram
  • Class diagram describes the structure of a
    system by showing the system's classes, their
    attributes, and the relationships among the
    classes.

10
Interaction Diagram
  • Represent string of messages that have been
    submit and receive and its relation
  • Example of 2 types
  • Sequence diagram based on sequence of time
    frame
  • Collaboration diagram represent the data flow

11
Sequence Diagram
12
Collaboration Diagram
13
Classes and Objects
  • Object-oriented programs use objects.
  • An object is a thing, both tangible and
    intangible. Account, Vehicle, Employee, etc.
  • To create an object inside the computer program,
    we must provide a definition for objectshow they
    behave and what kinds of information they
    maintain called a class.
  • An object is called an instance of a class.

14
Graphical Representation of a Class
15
Graphical Representation of an Object
16
An Object with the Class Name
17
Messages and Methods
  • To instruct a class or an object to perform a
    task, we send a message to it.
  • A class or an object must possess a matching
    method to be able to handle the received message.
  • A method defined for a class is called a class
    method, and a method defined for an object is
    called an instance method.
  • A value we pass to an object when sending a
    message is called an argument of the message.

18
Sending a Message
myWindow.setVisible(true) personA.deposit( 250.0
) student.setName(john) car1.startEngine( )
Examples
19
Sending a Message and Getting an Answer
20
Calling a Class Method
21
Class and Instance Data Values
  • An object is comprised of data values and
    methods.
  • An instance data value is used to maintain
    information specific to individual instances. For
    example, each BankAccount object maintains its
    balance.
  • A class data value is used to maintain
    information shared by all instances or aggregate
    information about the instances.
  • For example, minimum balance is the information
    shared by all Account objects, whereas the
    average balance of all BankAccount objects is an
    aggregate information.

22
Sample Instance Data Value
All three BankAccount objects possess the same
instance data value current balance.
The actual dollar amounts are, of course,
different.
23
Sample Class Data Value
24
Object Icon with Class Data Value
25
Class
  • Class name
  • Start with capital letter for each new word
  • Example Student, StudentAdvisory
  • Attributes
  • Represent the characteristics of the object
  • Variables,
  • Operation
  • Represent the behavior of the class
  • Methods, behaviors

26
Class/Attribute/Method/Object
Student
Class
name age course fees
Attribute (variable)
registerSubject withdrawSubject borrowBook
Method (operation)
Object
Object
StdDiploma
Std1
27
Java Code Class, Attribute, Method Declaration
public class Student // class name String
name // attribute _at_ variable
declaration int age 10 String course
DCS double fees 1067.60 public void
registerSubject () // code for
register subject
28
Java Code Object Declaration / Manipulation
public Class Student public static
void main (String data) Student
stdDiploma // declaring/creating an object
stdDiploma new Student() // object
initialize Student Std1 new Student()
// declaration and initialize
Std1.name " Amad // assigning value to
object Std1.age 24 // assigning value
to object System.out.println(" student name
" Std1.name) System.out.println("
student age registration " Std1.age)

29
Relationships among Classes
  • Association
  • Aggregation
  • Composition
  • Inheritance

30
Association
  • Association represents a general binary
    relationship that describes an activity between
    two classes.

An association is usually represented as a data
field in the class.
31
Aggregation
  • Whole-to-part associations
  • The concept representing the whole is called the
    aggregate each concept representing a part is
    called constituent.
  • The aggregate and the constituent may existed
    independently of each other.

32
Example of Aggregation
33
Composition
  • Whole-to-part associations
  • The concept representing the whole is called the
    composite each concept representing a part is
    called component
  • The composite does not exist independently from
    its component
  • The component may exist without the composite

34
Example of Composition
35
Aggregation vs Composition
AGGREGATION COMPOSITION
Name of whole Aggregate Composite
Name of part Constituent Component
Parts May be different types Usually the same type
Existence May exist without its parts Does not exist without its parts
Number of wholes to which a part may belong Part may belong to more than one aggregate at a time Part may belong to only one composite at a time
36
Inheritance
  • Inheritance is a mechanism in OOP to design two
    or more entities that are different but share
    many common features.
  • Features common to all classes are defined in the
    superclass.
  • The classes that inherit common features from the
    superclass are called subclasses.
  • We also call the superclass an ancestor and the
    subclass a descendant.

37
A Sample of Inheritance
  • Here are the superclass Vehicle and its
    subclasses Car, Boat and Truck.

Truck
38
Inheritance
  • Inheritance models the is-an-extension-of
    relationship between two classes.

public class Car extends Vehicle / Data
fields / / Constructors / / Methods
/ public class Boat extends Vehicle /
Data fields / / Constructors / /
Methods /
39
Inheritance Hierarchy
  • An example of inheritance hierarchy among
    different types of students.

40
Example of class diagram with multiplicities,
attributes and operations
41
Key Concepts
  • Variable
  • Constant
  • Inheritance
  • Superclass
  • Subclass
  • OOP
  • Class
  • Object
  • Message
  • Class and instance methods
  • Instance and class data values

42
Q A
Write a Comment
User Comments (0)
About PowerShow.com