35
아.아. 아. LHS87 FAÇADE

Five pattern(facade mediator_singleton_monostate_null)

  • View
    282

  • Download
    1

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Five pattern(facade mediator_singleton_monostate_null)

아 . 꿈 .사 . LHS87

FAÇADE

Page 2: Five pattern(facade mediator_singleton_monostate_null)

What is the Façade?

A facade is an object that provides a simplified interface to a larger body of code, such as a class library

-From WIKIPEDIA

n. ( 건물의 ) 정면 (front), ( 길에 접해 있는 ) 앞면 ; 겉보기 , 외관 , 허울

-From Naver Dictionary

Page 3: Five pattern(facade mediator_singleton_monostate_null)

Structure

Page 4: Five pattern(facade mediator_singleton_monostate_null)

Example

Page 5: Five pattern(facade mediator_singleton_monostate_null)

Code

Page 6: Five pattern(facade mediator_singleton_monostate_null)

1. make a software library easier to use and understand, since the facade has convenient methods for common tasks

What are the good points?

2. make code that uses the library more readable, for the same reason

3. reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system

4. wrap a poorly-designed collection of APIs with a single well-designed API

Page 7: Five pattern(facade mediator_singleton_monostate_null)

Thank you

Page 8: Five pattern(facade mediator_singleton_monostate_null)

MEDIATOR

아 . 꿈 .사 . LHS87

Page 9: Five pattern(facade mediator_singleton_monostate_null)

What is the Mediator?

n. 중재인 , 조정자 , 매개자 -From Naver Dictionary

Communication between

object is encapsulated with a mediator object. Objects no longer communicate directly with each other, but instead communicate through the mediator.

-From WIKIPEDIA

Page 10: Five pattern(facade mediator_singleton_monostate_null)

Terran Mediator

병사가 될 사람을 줘

전쟁 나갈 병사를 줘

가스

내놔

일꾼

내놔

배틀크루져 줘

식량

좀 줘

자원 내놔

Page 11: Five pattern(facade mediator_singleton_monostate_null)

Structure

Page 12: Five pattern(facade mediator_singleton_monostate_null)

Example

Page 13: Five pattern(facade mediator_singleton_monostate_null)

Code

Page 14: Five pattern(facade mediator_singleton_monostate_null)

Code

Page 15: Five pattern(facade mediator_singleton_monostate_null)

What are the good point?reduces the dependencies between communicating objectsthereby lowering the coupling

Page 16: Five pattern(facade mediator_singleton_monostate_null)

Thank you

Page 17: Five pattern(facade mediator_singleton_monostate_null)

아 . 꿈 .사 . LHS87

SINGLETON

Page 18: Five pattern(facade mediator_singleton_monostate_null)

What is the Singleton?

In software engineering the singleton pattern is a design pat-tern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object ex-ists, or that restrict the instantiation to a certain number of ob-jects (say, five).

-From WIKIPEDIA

n. 하나씩 일어나는 일 [ 것 ], 홀로인 것 , 독자 ( 獨子 )

-From Naver Dictionary

Page 19: Five pattern(facade mediator_singleton_monostate_null)

Structure

Page 20: Five pattern(facade mediator_singleton_monostate_null)

Code

Page 21: Five pattern(facade mediator_singleton_monostate_null)

Combination

Page 22: Five pattern(facade mediator_singleton_monostate_null)

Thank you

Page 23: Five pattern(facade mediator_singleton_monostate_null)

아 . 꿈 .사 . LHS87

MONOSTATE

Page 24: Five pattern(facade mediator_singleton_monostate_null)

What is the Monostate?mono- 《연결형》 「단일의 ; 단분자의 ; 【화학】 1 원자를 함유한」의 뜻(opp. poly-)

-From Naver Dictionary

The monostate enforces the behavior of a singleton without the structure of the monostate.

1. 깝탱2. 백설기3. 탱4. 탱구5. 꼬꼬마리더태연6. 때때7. 젤리

그녀의 별명들…

Symbolic link

Page 25: Five pattern(facade mediator_singleton_monostate_null)

Simple Code

Page 26: Five pattern(facade mediator_singleton_monostate_null)

1. 투명성 , 사용자가 이 객체가 MONOSTATE 라는 것을 알 필요가 없다 .

What are the good points?

2. 파생가능성 , 어떤 MONOSTATE 의 파생 클래스는 같은 MONOSTATE 의 일부

3. 다형성 , 파생 클래스에서 같은 정적 변수의 집합에 대해 서로 다른 동작 제공 가능

Page 27: Five pattern(facade mediator_singleton_monostate_null)

Singleton vs Monostatecreating a single state that all of the instances use.

limiting an object to a single instance of that ob-ject

can't be instantiated via normal mechanisms.developers always know whenthey're dealing with a sin-gleton

a different semantic to object instantiation but retains the same syn-tax.

Classes derived singleton classesare not singletons by default

all classes derived from a monostate are monostates.

Page 28: Five pattern(facade mediator_singleton_monostate_null)

Thank you

Page 29: Five pattern(facade mediator_singleton_monostate_null)

아 . 꿈 .사 . LHS87

NULL OBJECT

Page 30: Five pattern(facade mediator_singleton_monostate_null)

provides intelligent do nothing behav-ior, hiding the details from its collaborators.

What is the Null object?

Page 31: Five pattern(facade mediator_singleton_monostate_null)

Structure

Page 32: Five pattern(facade mediator_singleton_monostate_null)

Code

Page 33: Five pattern(facade mediator_singleton_monostate_null)
Page 34: Five pattern(facade mediator_singleton_monostate_null)

What are the good points?1. makes client code simple. Clients can treat real collabo-

rators and null collaborators uniformly. Clients normally don't

know (and shouldn't care) whether they're dealing with a real or a null collaborator.

2. makes the do nothing code in the null object easy to reuse. Mul-tiple clients which all need their collaborators to do nothing will

all do nothing the same way. If the do nothing behavior

needs to be modified, the code can be changed in one place. Thereafter, all clients will continue to use the same do noth-ing behavior, which is now the modified do nothing behavior.

Page 35: Five pattern(facade mediator_singleton_monostate_null)

Thank you