Abstract - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

Abstract

Description:

Kedua method ini akan dioverride, sementara dua method yang lain akan tetap generic. ... Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides ' ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 43
Provided by: ovieas
Category:
Tags: abstract | erich

less

Transcript and Presenter's Notes

Title: Abstract


1
Abstract InterfaceGOF Design Pattern
  • Tim Asisten Praktikum PSBO 08/09

2
Once upon a time..
Buat program tentang simulasi hewan untuk anak
sayaa!
Boss besar
Yawda, desain dulu aja..
Aha! Gimana kalo bikin hewan-hewan jadi objek?
3
1. Lihat atribut dan behaviour!
  • Atribut
  • picture
  • food
  • hunger
  • boundaries
  • location
  • Behaviour
  • makeNoise()
  • eat()
  • sleep()
  • roam()

4
2. Buat class
SUPERCLASS
SUBCLASS
Do all animals eat the same way?
5
3. Subclass memiliki behaviour yang lebih
spesifik.
Jadi, Kedua method ini akan dioverride, sementara
dua method yang lain akan tetap generic..
6
4. Lihat kesamaan behaviour yang lain..
7
Class Hierarchy
8
?
?
?
?
?
?
9
  • .. Some classes just should not be instantiated!

10
Abstract Class
  • Tidak dapat diinstantiasi -gt superclass
  • Class yang berisi satu atau lebih abstract method
  • Jika suatu kelas memiliki abstract method, maka
    kelas tersebut harus didefinisikan sebagai
    abstract class
  • Subclass harus mengimplementasikan abstract
    method superclassnya (abstract class)

11
Abstract Method
  • Method yang tidak memiliki body
  • Harus di override oleh subclassnya
  • Constructor dan static method tidak boleh
    abstract
  • Harus diimplementasikan oleh method dari subclass

12
Sooo.. Abstract..
Shape
drawabstract() void
13
Sintaks
  • Abstract Class
  • ClassModifier abstract class ClassName
  • contoh
  • public abstract class Shape
  • Abstract Method
  • Modifier abstract ReturnTypeMethodName
    (parameter)
  • contoh
  • public abstract void draw()

14
Sintaks
  • Subclass (pengguna abstract)
  • ClassModifier class ClassName extends
    AbstractClass
  • contoh
  • public class Segitiga extends Shape

15
Another case..
16
(No Transcript)
17
What if..
  • ..semua anggota abstract class adalah abstract
    method?

18
Interface
  • Interface adalah abstract class yang seluruh
    methodnya adalah abstract method.
  • Variabel dari interface selalu static dan final.
  • Bukan class, tapi prototype untuk class (yang
    nanti akan mengimplementasikan)
  • Sebuah class dapat mengimplementasikan lebih dari
    satu interface.

19
Interface sebagai Tipe Data
  • Dapat digunakan sebagai variabel sebuah class
  • Dapat digunakan sebagai parameter

20
Sintaks
  • Membuat interface
  • interface InterfaceName
  • Contoh
  • interface Animal
  • Menggunakan interface
  • ClassModifier class ClassName implements
    InterfaceName
  • Contoh
  • public class Cat implements Animal

21
Pewarisan antar interface
  • Interface dapat mewarisi interface lainnya
  • Contoh
  • interface Animal
  • /some code/
  • interface Mammal extends Animal
  • /some code/

22
Class Diagram
23
Latihan
  • Refer to labwork_05.pdf

24
Rational Objectory
  • Software Engineering Process
  • Its goal is to ensure
  • the production of high-quality software
  • meeting the needs of its end-users
  • within a predictable schedule and budget

25
Objectory
  • Objectory adalah suatu proses iterasi atau bisa
    juga diartikan sebagai suatu proses terkontrol
  • Jadi objectory adalah proses iterasi terkontrol
  • Objectory focus pada arsitektur dari sistem
  • Aktifitas pengembangan objectory diarahkan oleh
    use case, object oriented proses, penggunaan UML
    sebagai pemodelan dan bisa di konfigurasi untuk
    menentukan ruang lingkup suatu project

26
Objectory (cont)
  • Objectory proses dibagi menjadi 4 phase yang
    membentuk pola pengembangan cycle
  • Inception phase/ fase permulaan
  • Elaboration phase/ fase perluasan
  • Construction phase/ fase pembentukan
  • Transition phase/ fase transisi

27
Objectory (cont)
Setiap fase di tutup oleh suatu milestone, yaitu
suatu keadaan di mana beberapa keputusan critical
harus dibentuk
28
Once upon a time.. (AGAIN)
Bagus juga desain Animalmu! ?
Sekarang.. ..tolong bikinin simulai bebek2an buat
anak kedua saya..
Boss besar
29
(No Transcript)
30
(No Transcript)
31
(No Transcript)
32
(No Transcript)
33
What do you think about this design?
34
Design Pattern
  • Muncul masalah ketika membuat program OOP
  • Handle Object
  • Perubahan pada sistem
  • Bagaimana biasanya programmer mengatasi masalah?
  • Some say, Pengalaman! Semakin banyak pengalaman
    seorang designer software, semakin elegant,
    simple dan flexible-lah code-nya. ?
  • New problem TIME

35
Design Pattern
  • Solusi yang sama untuk problem yang sama yang
    berulang-ulang
  • Learning curve yang hanya bisa didapat dari
    pengalaman dapat di kurangi

36
GoF Design Pattern
  • Gank of Four (GoF)
  • Erich Gamma, Richard Helm, Ralph Johnson, John
    Vlissides
  • Design Patterns Elements of Reusable
    Object-Oriented Software

37
GoF Design Pattern
  • Creational (C) 
  • Factory Method, Abstract Factory, Builder,
    Singleton, Prototype
  • Structural (S) 
  • Decorator, Composite, Proxy, Adapter, Bridge,
    Flyweight, Façade 
  • Behavioral (B) 
  • Strategy, Iterator, Template Method, Mediator,
    Observer, Chain of Responsibility, Memento,
    Command, State, Visitor, Interpreter

38
Strategy Pattern
  • Motivation
  • "Define a family of algorithms, encapsulate each
    one, and make them interchangeable. Strategy lets
    the algorithm vary independently from the clients
    that use it." Gamma, p315
  • Capture the abstraction in an interface, bury
    implementation details in derived classes

39
Structure
40
Contoh
41
(No Transcript)
42
GOF Design Pattern
  • ..to be continue..
Write a Comment
User Comments (0)
About PowerShow.com