程序代写代做代考 database Lecture 4: Design Patterns II

Lecture 4: Design Patterns II

The Final Stretch

!  Immutable

!  Proxy

!  Observable

!  Read Only Interface

Immutable

!  How do you create a class who’s instances are
immutable?
!  You can’t edit attributes after creation

Proxy

!  How do you make access to heavyweight classes easier?
!  For example, a database is an example of a heavyweight

class

Observable

!  How can you allow classes to communicate with each
other without knowing which class they belong to?

Read Only Interface

!  How do you allow certain classes to modify objects while
restricting access to others?

Pair the Pattern with the Diagram

!  Based on the code, match it to one of our remaining patterns.

!  How would this pattern be used in code? (what would the main
method look like?)

!  What forces can influence the implementation of the pattern?

!  What anti-patterns exist, and how would they be implemented?

PI Questions

¤ Join YACRS session: 1200

Proxy Pattern

!  The proxy pattern is implemented in:

!  A: Pattern1

!  B: Pattern2

!  C: Pattern3

!  D: Pattern4

Observer Pattern

!  The observer pattern is implemented in:

!  A: Pattern1

!  B: Pattern2

!  C: Pattern3

!  D: Pattern4

Immutable Pattern

!  The immutable pattern is implemented in:

!  A: Pattern1

!  B: Pattern2

!  C: Pattern3

!  D: Pattern4

Read Only Interface Pattern

!  The read only interface pattern is implemented in:

!  A: Pattern1

!  B: Pattern2

!  C: Pattern3

!  D: Pattern4

Break

!  For 10 minutes

Design Patterns Review: More codes

Abstraction Occurrence

General Hierarchy

Player Role

Singleton

Observer

Delegation

Adaptor

Façade

Immutable

Read-Only Interface

Proxy

Factory

Next Week

!  Read Chapter 9 of OOSE book

!  There will be a quiz