1 / 11

The Strategy Pattern

The Strategy Pattern. Tujuan Pembelajaran. Mengetahui model persoalan yang menggunakan Strategy pattern Mengetahui pola Strategy pattern Mampu menerapkan Strategy pattern untuk meningkatkan fleksibilitas kode. Koleksi Desain Pattern. Creational Patterns : Singleton Factory

Télécharger la présentation

The Strategy Pattern

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. The Strategy Pattern

  2. TujuanPembelajaran Mengetahui model persoalan yang menggunakan Strategy pattern Mengetahuipola Strategy pattern Mampumenerapkan Strategy pattern untukmeningkatkanfleksibilitaskode

  3. KoleksiDesain Pattern • Creational Patterns : • Singleton • Factory • Behavioural Patterns : • Strategy

  4. Behavioural Patterns Berkaitandengan “perilaku” objek Mengidentifikasipolakomunikasiumumantarobjekdanmerealisasikanpola-polaini Dapatmeningkatkanfleksibilitas

  5. Persoalan Program harusmendukungperilaku-perilaku yang berbedadariobjek-objek

  6. OO Design Principles Identify aspects that vary and separate them from what stays the same. Program to an interface not an implementation. Favor composition over inheritance

  7. Pisahkanperilakudarikelas Duck!

  8. Strategy Pattern -- Definisi The Strategy Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

  9. Strategy Pattern Template

  10. Latihan Jikaterdapattambahansatujenis Duck, yaituDecoyDuck yang tidakbisaterbangdantidakbisamengeluarkansuara. Tuliskankode Java untukkelasDecoyDuck. Jikasekarangperilakuberenang (swim) dibedakanmenjadiberenangdanmengambang, bagaimanakahperubahanstrukturkelasnya? Gambarkandengan class diagram. Tuliskankodeuntukkelas-kelas yang berubah.

More Related