Skip to content

akashs4/strategy-design-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Strategy Design Pattern defines a family of algorithms, encapsulate each one and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

Given example has a Duck class in which quack and fly behaviors are separated(since they can vary from duck to duck) from the rest of class that does not vary. For example: A toy duck can squeak and not fly but a normal duck can fly and quack.

Design Principles

  1. Identify the aspects of your application that vary and separate them from what stays the same.
  2. Program to an Interface and not an implementation.
  3. Favour composition over that interface.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages