W6: Pattern: Facade

The pattern Facade is part of structural design patterns.

Some subsystems contain several classes which are in close relation to each other. Since most classes of this subsystem are not commonly used without any other classes, there is no need to access them. The Facade then defines an consistent programming interface from which selected methods can be accessed.

Those methods are called delegate methods which keep the full access inside the subsystem. Thus handling of a Facade appears to be very easy.

Advantages

  • less dependency (hidden subsystem)
  • less complexity (consistent interface)
  • easy to expand

Disadvantage

  • adds another layer (more indirect)

Android App (small) example: WaveEffect

SmartSelect_20180528-233132_react.gif
WaveEffect in action
Facade before
before
Facade after
after

Code example (WaveEffect and how it affects SpriteMapObject)

facade
WaveEffect and SpriteMapObject before and after
Design a site like this with WordPress.com
Get started