filmov
tv
02. Strategy pattern
Показать описание
#OODP #ObjectOrientedDesignPattern #ObjectOriented
The Strategy pattern is a pattern that allows you to switch between several specific operation methods as needed. It creates several 'modes', each performing a given function, and allows you to choose which one to use. For example, shopping carts at a large supermarket's checkout counter perform the 'payment' function in various ways.
This is illustrated in an example of implementing the Strategy pattern, creating an interface called 'PaymentStrategy', and creating two classes that implement it, 'CreditCardPayment' and 'PayPalPayment'. These two classes fall into the 'PaymentStrategy' category, each implementing a 'pay' method. The important point here is that objects of the two classes can take the place of the 'PaymentStrategy' and execute the 'pay' method.
Also, the 'ShoppingCart' class has a 'PaymentStrategy' field, and the 'pay' method of the selected strategy is executed when calculating. In this way, the strategy pattern allows not only to change the algorithm as much as possible during code execution, but also to create a new strategy class if needed, and reuse it elsewhere.
As a result, the strategy pattern helps to create code that complies with the SOLID 'Open/Closed Principle'.
The Strategy pattern is a pattern that allows you to switch between several specific operation methods as needed. It creates several 'modes', each performing a given function, and allows you to choose which one to use. For example, shopping carts at a large supermarket's checkout counter perform the 'payment' function in various ways.
This is illustrated in an example of implementing the Strategy pattern, creating an interface called 'PaymentStrategy', and creating two classes that implement it, 'CreditCardPayment' and 'PayPalPayment'. These two classes fall into the 'PaymentStrategy' category, each implementing a 'pay' method. The important point here is that objects of the two classes can take the place of the 'PaymentStrategy' and execute the 'pay' method.
Also, the 'ShoppingCart' class has a 'PaymentStrategy' field, and the 'pay' method of the selected strategy is executed when calculating. In this way, the strategy pattern allows not only to change the algorithm as much as possible during code execution, but also to create a new strategy class if needed, and reuse it elsewhere.
As a result, the strategy pattern helps to create code that complies with the SOLID 'Open/Closed Principle'.
02. Strategy Pattern Implementation
02. Strategy Pattern Implementation
Applying the Strategy Pattern in Kotlin
The Strategy Pattern Explained and Implemented in Java | Behavioral Design Patterns | Geekific
Modular Upgrades Made Easy Using the Strategy Pattern
Strategy Pattern explained with Visual and Code example
The Strategy Pattern Will Make Your Python Code CLEANER
Solving A Common Issue With The Strategy Pattern // In Python
Revolutionize Crypto Trading: Candlestick Pattern Scanner Software | Find Patterns Instantly!
Strategy design pattern tutorial | Part 2: Java implementation
Design Patterns - Strategy Pattern with Nodes
Clean iOS Architecture 101: The Strategy Pattern
5 Design Patterns Every Engineer Should Know
JavaScript Example - Strategy Pattern
Strategy Design Pattern | Simple Calculator
Strategy Pattern – Design Patterns (ep 1) | LOW LEVEL DESIGN | Techie007 | Sukhad Anand
Strategy - Software Design Patterns | Head First
Strategy Pattern in Java 8
Javascript Design Patterns #3 - Strategy Pattern
1.2.Strategy Pattern
Design Patterns - Strategy Pattern
Change Class Behavior At Runtime! || Strategy Pattern Tutorial
Strategy Design Pattern (Software Design Patterns Tutorial)
Strategy Design Pattern | GOF Design Pattern | Software Architecture
Комментарии