1 / 21

Intro to OOP

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

rosa
Download Presentation

Intro to OOP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Intro to OOP Yesi Novia, S.Kom

  2. Perkembangan Orientasi Software • 1960-1970 Process-Orientation – Process models – Data Flow Diagrams, Flow Charts • 1980 Data-Orientation – Data models – Entity-Relationship (ER) Diagrams • 1990 Object-Orientation – Object models – Class Diagrams, Event Diagrams • 2000 –UML- standarisasi OOD

  3. “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]

  4. 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 • 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 Car LightBulb • state/attributes • balance • behavior • deposit • withdraw • check balance BankAccount

  5. So, What objects are ? • Representasi sebuah individu, benda, unit, entitas, real ataupun abstrak dengan peran yang jelas dalam domain permasalahan

  6. 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 = +

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

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

  9. Prinsip-prinsip OOP • Class • Inheritance • Enkapsulasi • Polimorfisme

  10. 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

  11. Kelas dan objek

  12. Kelas dan objek (2)

  13. BankAccount.java public class BankAccount { private double balance; public BankAccount() { balance = 0; } public double getBalance() { return balance; } public void deposit( double amount ) { balance = balance + amount; } … } Kelas dan objek (3) • 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 ); Constructor call Method call

  14. Enkapsulasi • “Information hiding” • Data dan cara untuk mendapatkan data (code) dibungkus dalam sebuah paket dan dilindungi dari intervensi luar

  15. Inheritance • Sebuah kelas menurunkan karakteristiknya ke kelas lain A car is a vehicle A dog is an animal A teacher is a person

  16. OOP : Pewarisan 16

  17. Polimorfisme • Mempunyai beberapa bentuk / forms • Memungkinkan objek yang berbeda untuk merespon sebuah pesan yang sama dengan cara masing-masing

  18. 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 ?

  19. OOP : Polimorfisme geometri getGeometri() luas() keliling() persegi bujur lingkaran getGeometri() luas() keliling() getGeometri() luas() keliling() getGeometri() luas() keliling() abstract class concrete class

  20. 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 ?

  21. 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 ?

More Related