filmov
tv
This Decorator Pattern Implementation Will Make Your Day!

Показать описание
Decorator is one of the fundamental design patterns. It has wide range of applications in programming, though we might sometimes feel it is neglected.
This video is analyzing the problem we encounter when a method receives an IComparer, but what we need is its reverse. Like sorting the data vs. sorting descending. All we have is an IComparer that compares in ascending order, but no opposite one.
In this video, you will learn how to apply the Decorator design pattern to solve problems like this one. We will create a special-purpose IComparer which reverses the decision of another IComparer, even without knowing how it works.
Before the end, we will even design an optimizing static factory for the reversing comparer, so that if a comparer is reversed two times in a row, all decoration is removed from it so to save execution time.
Chapters:
00:00 Intro
01:01 Inventing the Decorator pattern
02:23 IComparable decorator used by List
03:22 Implementing the ReverseComparer class
05:05 Implementing the optimized decorator factory
08:02 Using the decorator
Learn more from video courses:
Other videos on this channel you may be interested in watching:
Комментарии