From the course: Node.js: Design Patterns
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Implementing strategies - Node.js Tutorial
From the course: Node.js: Design Patterns
Implementing strategies
- [Narrator] In the last lesson we introduced the strategy design pattern and discovered how we could work with it. In this lesson we're going to implement the pattern by creating several log strategies in a single class. So, the first thing we want to do is encapsulate all of our strategies, all of our algorithms in a single class in a single file. So I'm going to go over here to the start folder. We are in the exercise files for chapter four, chapter four lesson 11 and within that start folder we have the index code that we changed to use the change strategy on line seven as well as the config.json file where we are able to set the strategy before the application gets started. So let's go ahead and add another file to this called log strategy.js and what we want to do in this file is create a class that we call log strategy and we're never going to instantiate any objects with this class. What we're going to do is just save several static methods to this class and each static method…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Chain of responsibility4m 42s
-
(Locked)
Implementing the storage class6m 22s
-
(Locked)
The Command pattern4m 47s
-
(Locked)
Implementing commands4m 59s
-
(Locked)
Improving the conductor6m 38s
-
(Locked)
The Iterator pattern4m 5s
-
(Locked)
Implementing iterators4m 59s
-
(Locked)
The Observer pattern4m 19s
-
(Locked)
Implementing observers2m 48s
-
(Locked)
The Strategy pattern4m 25s
-
(Locked)
Implementing strategies9m 36s
-
(Locked)
-