From the course: Node.js: Design Patterns
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Implementing decorators - Node.js Tutorial
From the course: Node.js: Design Patterns
Implementing decorators
- [Instructor] In the last lesson, we defined the decorator pattern, as well as added a couple of decorator classes to some existing code. I'm looking at the exercise files found under Chapter Three, Lesson Eight, within the Start folder. We added the GoldenInventoryItem and DiamondInventoryItem to this index.js file, and we also created golden necklaces, A Diamond Gold Necklace, and a Diamond Walkman. In this lesson, we need to actually write the code for the GoldenInventoryItem and DiamondInventoryItem decorator classes. So let's go ahead and open up our inventory item file. So we'll go ahead and add the decorators right here, next to the InventoryItem. So I'm going to go ahead and add a class GoldenInventoryItem, and a class for DiamondInventoryItem, and we're just going to export all three of these things together within the same object, so I'll make sure that I export my GoldenInventoryItem class and…
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)
The Adapter pattern2m 20s
-
(Locked)
Implementing an adapter6m 24s
-
(Locked)
The Proxy pattern2m 11s
-
(Locked)
Implementing a proxy5m 48s
-
(Locked)
The Composite pattern3m 12s
-
(Locked)
Implementing composites5m 59s
-
(Locked)
The Decorator pattern4m 3s
-
(Locked)
Implementing decorators4m 24s
-
(Locked)
-
-