Skip to content

LH17/Behavioral-Design-Pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Behavioral-Design-Pattern

Behavioral Design Pattern deals with how objects interact. It describes how objects communicates with each other and how the steps of a task is broken among different objects so as to provide more flexibility and make the code more testable.

Contents

If you are looking for something specific, you can jump right into the relevant section from here.

  1. Chain Of Responsibility Design Pattern
  2. Command Design Pattern
  3. Iterator Design Pattern
  4. Mediator Design Pattern
  5. Memento Design Pattern
  6. Observer Design Pattern
  7. State Design Pattern
  8. Strategy Design Pattern
  9. Template Design Pattern
  10. Visitor Design Pattern

Chain Of Responsibility Design Pattern

Chain of Responsibility is a behavioural design pattern that let us pass the requests among a chain of handlers where each handler decides either to process the request or to pass it along the chain.

Command Design Pattern

In Command pattern, the class that executes the command(called Invoker) is decoupled from the class which produces the command(ConcreteCommand) and from the class that knows how to perform it.(Receiver)

Iterator Design Pattern

This pattern is used for iterating over a collection of elements. It does not expose the data structure used in implementing it (array, dictionary or linked list) rather it gives an interface which iterates over the collection of elements without exposing its underlying representation.

Mediator Design Pattern

Let us take a scenario when two or more classes has to interact with each other. Instead of directly communicating with each other and getting the knowledge of their implementation, they can talk via a Mediator.

Memento Design Pattern

Memento Pattern captures the current state of an object and store it in such a way that you can retrieve it at a later time when you would like to return to the previous state.

Observer Design Pattern

In this pattern, one object notifies other objects about its state change i.e. when the state of one object changes, other object which are subscribed to it gets notified about the state change. So, it is a one-to-many relationship. The object whose state changes are called observable or subject and the objects which subscribe for changes on the observable are called observers.

State Design Pattern

State design pattern is a design pattern where an object needs to change his behavior when its internal state has changed. It appears as if the object changed its class.

Strategy Design Pattern

This pattern defines a family of algorithms: each one of them written in a separate class allowing us to select which algorithm to execute at runtime.

Template Design Pattern

In this pattern, the base class defines the template of an algorithm and let the subclass implement these abstract methods in the same way they are defined in the base class without changing the overall structure.

Visitor Design Pattern

Visitor design pattern separates the algorithms from the objects on which they operate i.e. the operational logic is moved from each elements of a group into a new class. The new class will perform the operational logic using the data from those elements.

For more, check the Medium Blog

About

Behavioral Design Patterns in swift

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages