Professional Documents
Culture Documents
Keuntungan object-oriented:
Reusability
Modularity
Maintainability
Object adalah suatu abstraksi dari sesuatu dalam suatu domain masalah,
menyatakan kemampuan sistem untuk :
menyimpan informasi tentang object tsb,
berinteraksi dengan object tsb,
atau keduanya
Object Class
Class adalah deskripsi dari sekumpulan object yang membagi (share)
attributes, methods, relationship dan semantic yang sama;
Object class adalah template untuk object, yang dapat digunakan untuk
membuat object,
Object menyatakan suatu kejadian khusus tertentu dari suatu class
Contoh:
Class Object
name: string name: John
address: string 3 address: M Street No.23
dateOfBirth: date dateOfBirth: 02/10/65
employeeNo: integer employeeNo: 324
socialecurityNo: string socialecurityNo:E342545
department: string department: Sale
manager: string manager: Employee1
salary: real salary: 2340
status: {current, left, retired} status:current
taxCode: integer taxCode: 3432
Join( ) Eployee16.join(02/05/1997)
Retire( ) Eployee16.retire(03/08/2005)
ChnageDetail( ) Eployee16.changeDetail(“X Street
9559883.doc 1
No. 12”)
Inheritance
Object classes dapat menurunkan atribut dan services dari object
class yang lain,
Inheritance menyatakan suatu generalisasi suatu class,
Generalisasi
Employee
Ma nager Programmer
budgetsControlled project
progLanguage
dateAppointed
Library item
Catalogue number
Acquisition date
Cost
Type
Status
Number of copies
Acquire ()
Catalogue ()
Dispose ()
Issue ()
Return ()
9559883.doc 2
Keuntungan Inheritance:
Multiple Inheritance
Talking book
# Tapes
Suatu object class dapat pula dibentuk dari turunan beberapa super-
class,
Akan memberikan dampak konflik semantic dimana atribut/service
dengan nama yang sama pada super-class yang berbeda memiliki
semantic yang berbeda
Membentuk hierarchy yang lebih kompleks
Object Agregasi
Model agregasi menunjukkan bagaimana class-class dibentuk dari class
yang lainnya
Similar dengan relasi: part-of dalam model data semantic
9559883.doc 3
Study pack
Course title
Number
Year
Instructor
1 1 1 1
1 1 1 0
Assignment OHP slides Lecture Videotape
notes
Credits Slides Text Tape ids.
1 1
1 1
Exercises Solutions
#Problems Text
Description Diagrams
Encapsulation
Customer
- numCustomers = 0
private attributes - MIN_BUDGET = 200
- name: String
- address: String
- budget: int
9559883.doc 4
Komunikasi dalam object
message
name = “Alex”
takeOrder(“sofa”, name, name = “Lawrence”
address = employeeNo =15
address, “120799”)
“1 Robinson Rd”
commission = 200
budget = 2000
19
placeOrder( ): void 9 takeOrder( ): int
return value
alex lawrence
message
9559883.doc 5
Polymorphism
Kemampuan object yang berbeda untuk menjalankan method yang
sesuai untuk merespon ke pesan yg sama
Pemilihan method yang sesuai tergantung pada class yg digunakan
untuk membuat object
name
Shape getName( )
calculateArea( )
radius side
Circle Square
calculateArea( ) calculateArea( )
Contoh:
class Shape {
private String name;
public Shape(String aName) { name=aName; }
public String getName( ) { return name; }
public float calculateArea( ) { return 0.0f; }
} // End Shape class
class Circle extends Shape {
private float radius;
public Circle(String aName) { super(aName); radius = 1.0f; }
public Circle(String aName, float radius) {
super(aName); this.radius = radius;
}
public float calculateArea() { return
(float)3.14f*radius*radius; }
} // End Circle class
class Square extends Shape {
private float side;
public Square(String aName) { super(aName); side = 1.0f; }
public Square(String aName, float side) {
super(aName); this.side = side;
}
public float calculateArea() { return (float) side*side; }
} // End Square class
public class ShapeDemoClient {
public static void main(String argv[ ]) {
Shape c1 = new Circle("Circle C1");
Shape c2 = new Circle("Circle C2", 3.0f);
Shape s1 = new Square("Square S1");
Shape s2 = new Square("Square S2", 3.0f);
Shape shapeArray[ ] = {c1, s1, c2, s2};
for (int i = 0; i < shapeArray.length; i++) {
System.out.println("The area of " + shapeArray[i].getName( )
+ " is " + shapeArray[i].calculateArea( )
+ " sq. cm.");
}
} // End main
9559883.doc 6
} // End ShapeDemoClient1 class
OO Analysis: mencari kebutuhan dari perpektif class dan object yang ditemukan
dalam suatu vocabulary dari domain masalah. Dengan kata lain, world (system)
dimodelkan dalam bentuk object dan class,
OO Design: Dekomposisi OO dan suatu notasi untuk menggambarkan model
system pada tahap pengembangan. Struktur dibentuk setelah object yang
berhubungan dengan system sudah didefinisikan.
OO-Analisis:
Student to Catalog
Staff
Got to Loaned
Book Charge
Return Magazine
Give Journal
List of
Check Loaned
Book
Check
Check
Late Loaned
Returne
Warned to Process
return book the Loan
Pay the Appr
9559883.doc 7
Get the
Class Fitting
Student Staff
ID ID
Name Name
dateOfBirth dateOfBirth
…. Department:
Join ( )
Register( )
ChangItems( ) AssignDept( )
…. ….
Object Relations
loan
Student Book
Checked / served by
loanedBook
Staff
BookID
loanDate
studentID
Package
LoanProces
Studen searc B
addLoanedBoo
loanedBoo
9559883.doc 8
Unified Modelling Language
The Unified Modeling Language (UML) is a standard
language for writing software blueprints.
The UML may be used to visualize, specify, construct,
and document the artifacts of a softwareintensive system.
Building Blocks
Things
Relationships
Diagrams
Things:
Structural things
classes, interfaces, collaborations, use cases, active classes, components,
nodes.
Behavioral things
interactions, state machines.
Grouping things
packages.
Annotational things
notes.
Sha pe
origin
mov e()
resize()
display ()
Class Inheritance
< <Cl ass Mo dul e>>
Shape
origin : Variant
move()
resize()
display()
Square
9559883.doc 9
Class - Dependencies
A change in specification of one thing may effect another thing that
uses it
FilpClip
name
playOn() Channel
start()
stop()
reset()
Class – Association
A structural relationship that specifies that objects of one thing are
connected to objects of another.
Name: name of association
Role: a specific role of class in an association
Multiplicity, an association represent a structural relationship
among objects: zero to one(0..1), many(0..*) or one or more (1..*)
Aggregation: a plain association between two classes represents
a structural relationship “whole-a-part”
Association, Multiplicity, Aggregation and Role
0
ha Department
Scho s
ol 1 1 1
1 1
Assigns
memb
to
er 1
* 1 1 chairper
attend teac Instructo
Stude s Cours
nt * * e r
9559883.doc 10
Structural Things – Use Case
Specifies the behavior of a system or a part of a system and is a description
of a set of sequences of actions, including variants, that a system performs
to yield an observable result of value to an actor.
Process Loan
LoanOf fic er
RetailInstitution
Customer
Reconcile Transaction
Sponsoring
Financial
Statechart Diagram
A statechart diagram shows a state machine, consisting of states,
transitions, events, and activities.
9559883.doc 11
S tart
Meminta Memberi
Informasi Informasi
Melen gkapi
Persyara tan
Menyerahkan
Persyarat
Cek Persyaratan
[Tidak Lengkap]
[L engkap]
Mencatat
Pendafta ran
End
Activity Diagram
An activity diagram is a special kind of a statechart diagram that
shows the flow from activity to activity within a system.
Prepare Text
TO Visaul
Read Text
Generate
Ge sture Generate
Phoneme
Gene rate
Speech Generate Lip
Articulation
Clean Buffer
9559883.doc 12
Sequence Diagram
A sequence diagram is an interaction diagram that emphasizes the
timeordering of messages.
: Petugas : Layar Utam a Sis tem : Mem buat : Form ulir Pendaftaran : Pendaftaran
Loket Pendaftaran Pendaftaran Baru
1 : Pen daftaran Baru( ) Baru
2: Pendaftaran Baru( )
5: Masukan Pendaftaran( )
6: Buat Pendaftaran( )
Component Diagram
Component diagram shows an organization and dependencies of
a group of components.
Deployment Diagram
Deployment diagram shows the configuration of run-time node
processing and its components.
9559883.doc 13
Server SIMTAP <<network>> Komputer Pej abat
WAN SOPD
<<network>>
LAN
Komputer Bupati
Komputer Loket Komputer Loket Komputer Sekreteris
Pendaftaran Penyerahan
9559883.doc 14