In this video Emmanuel Henri explains the strategy pattern with an example.
- [Narrator] The strategy pattern is basically a way…to encapsulate different algorithms or functions.…And then at round time,…practically use the same code to run different scenarios.…Now we've used this approach in some of the code…we've written thus far.…So let's open the exercise files,…and let's take a look at Chapter Four,…and in this case Video Five,…and open these files here.…So what you could do,…you can drag and drop into Visual Studio Code,…and open the files here.…
So this is something that we've done…in the past in this course.…We've basically created a class called Car…and then extended that to an SUV…but the strategy pattern is where we're…actually doing this here.…So we're doing practically the same type of code,…but doing different strategy for that code…to represent something different.…So this is how simple the strategy pattern gets.…So you basically defining some classes here…and then you're leveraging this same code here…new Car,…or you could do multiple cars,…and then SUVS to create different objects.…
- What's a pattern?
- What's the role of callbacks?
- Creational patterns, including Singleton and Factory
- Structural patterns, including model-view-controller
- Behavioral patterns, including Memento and Mediator
Skill Level Intermediate
2. Creational Patterns
3. Structural Patterns
4. Behavioral Patterns
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.