Skip to content

TrabelsiAchraf/DesginPatterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DesginPatterns

Table Of Contents

Behavioral :

Observer Pattern

  • One object notifies other objects about its state change.
  • It is a one-to-many relationship.
  • When the state of one object changes, other object which are subscribed to it gets notified about the state change.
  • Observable protocol has three abstract methods :
    • add(observerX) : to add an observer.
    • remove(observerX) : to remove a specific observer.
    • notify() : to notify all observers.

Code example here

Implementation

Demo

Strcutural :

Adapter Pattern

  • Named also Wrapper.
  • Allows objects with incompatible interfaces to collaborate.
  • lets you create a middle-layer class that serves as a translator between your code and a legacy class, a 3rd-party class or any other class with a weird interface.
  • Do not add an additional behavior.

Code example here

Implementation

Demo

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages