intro to oop
DESCRIPTION
Intro to OOP. Yesi Novia, S.Kom. Perkembangan Orientasi Software. 1960-1970 Process-Orientation – Process models – Data Flow Diagrams, Flow Charts 1980 Data-Orientation – Data models – Entity-Relationship (ER) Diagrams 1990 - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/1.jpg)
Intro to OOP
Yesi Novia, S.Kom
![Page 2: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/2.jpg)
Perkembangan Orientasi Software• 1960-1970 Process-Orientation – Process models – Process-Orientation – Process models –
Data Flow Diagrams, Flow ChartsData Flow Diagrams, Flow Charts• 19801980
Data-Orientation – Data models – Entity-Data-Orientation – Data models – Entity-Relationship (ER) DiagramsRelationship (ER) Diagrams
• 19901990Object-Orientation – Object models – Object-Orientation – Object models – Class Diagrams, Event DiagramsClass Diagrams, Event Diagrams
• 2000 –UML- standarisasi OOD2000 –UML- standarisasi OOD
![Page 3: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/3.jpg)
• “An object is an encapsulation of state (data values) and behavior (operations). Thus an object is in many ways similar to a module, or an abstract data type." [Budd]
• ”An object has state, behavior, and identity; [Booch 91]
![Page 4: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/4.jpg)
• state/attributes– on (true or false)
• behavior– switch on– switch off– check if on
state/attributes # of liters of gas in tank total # of km run so far efficiency (km/liter)
behavior drive load gas change efficiency check gas check odometer reading
LightBulbCar
BankAccount
state/attributes balance
behavior deposit withdraw check balance
Note each object is an
“instance” of that “class” of object
each instance has its own values for its attributes
e.g., different accounts can have different balances
![Page 5: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/5.jpg)
So, What objects are ?
• Representasi sebuah individu, benda, unit, entitas, real ataupun abstrak dengan peran yang jelas dalam domain permasalahan
![Page 6: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/6.jpg)
Sebuah objek terdiri dari
• Atribut know something- Data yang dimiliki objek- Cara untuk mendeskripsikan objek
• Operasi do something- Tindakan atau aksi yang dilakukan objek
yang akan mempengaruhi atribut
= +
![Page 7: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/7.jpg)
Mengapa?
• Modularity– Dapat dipecah menjadi bagian-bagian kecil
• Reusability– Komponen yang digunakan pada proyek
sebelumnya dapat digunakan kembali
• Extensebility– Komponen yang baru dapat dikembangkan
dari komponen yang sudah ada
![Page 8: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/8.jpg)
Prosedural VS OOP
• Prosedural– Mempunyai kemampuan untuk
membangun proyek yang tangguh dan handal dalam skala besar
– Tidak bersifat reusable dan extensible– Membutuhkan waktu dan biaya yang lebih
besar untk memperluas atau menggunakan kembali komponen yang sudah ada
• OOP– Bersifat reusable dan extensible
![Page 9: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/9.jpg)
Prinsip-prinsip OOP
• Class• Inheritance• Enkapsulasi• Polimorfisme
![Page 10: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/10.jpg)
Class
• Cetak biru dari sebuah objek, atribut dn operasi yang dimilikinya
• Contoh : buku bisa saja berupa kelas
• Objek : buku bahasa pemrograman java dengan no ISBN :….
• Objek adalah perwujudan kelas INSTANCE
![Page 11: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/11.jpg)
Kelas dan objek
![Page 12: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/12.jpg)
Kelas dan objek (2)
![Page 13: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/13.jpg)
Kelas dan objek (3)
public class BankAccount{ private double balance;
public BankAccount() { balance = 0; }
public double getBalance() { return balance; }
public void deposit( double amount ) { balance = balance + amount; } …}
BankAccount.java
Constructor: special method that handles initialization
Java Example: BankAccount
A constructor is invoked during object construction:BankAccount b;b = new BankAccount();b.deposit( 100.00 );
Method call
Constructor call
![Page 14: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/14.jpg)
Enkapsulasi
• “Information hiding”• Data dan cara untuk mendapatkan
data (code) dibungkus dalam sebuah paket dan dilindungi dari intervensi luar
![Page 15: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/15.jpg)
Inheritance
• Sebuah kelas menurunkan karakteristiknya ke kelas lain
A car is a vehicle
A teacher is a person
A dog is an animal
![Page 16: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/16.jpg)
16
OOP : Pewarisan
![Page 17: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/17.jpg)
Polimorfisme
• Mempunyai beberapa bentuk / forms• Memungkinkan objek yang berbeda untuk
merespon sebuah pesan yang sama dengan cara masing-masing
![Page 18: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/18.jpg)
• Abstract class class yang menyimpan aspek generic dari sub class tanpa implementasi tidak memiliki body, body digantikan dengan (;)
• Concrete class subclass dari abstract class mengimplementasikan abstract class
Abstract vs Concrete Class ?
![Page 19: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/19.jpg)
OOP : Polimorfisme
getGeometri()luas()keliling()
bujur
getGeometri()luas()keliling()
lingkaran
getGeometri()luas()keliling()
geometri
getGeometri()luas()keliling()
persegi
abstract class
concrete class
![Page 20: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/20.jpg)
• Use case driven saat analisa memperhatikan use case
• Architecture centric saat desain memperhatikan arsitektur fungsional, static, dynamic dari sistem
• Iterative & Incremental (berulang dan bertambah ) mudah untuk dipakai ulang ataupun diupgrade
Konsep ADBO ?
![Page 21: Intro to OOP](https://reader036.vdocuments.us/reader036/viewer/2022081603/568150b2550346895dbecf43/html5/thumbnails/21.jpg)
• Customer : work, keep working, upgraded• Programmer : well designed, easy to maintain, reuse• “Give them what they want”
Bagaimana caranya?Tergantung pada bagaimana mendecomposisikan,
menguraikan, mengiris-iris problem
Great Software ?