Become a patron and get access to source code and exclusive live streams: 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. You can find a more detailed explanation and implementation of the Decorator design pattern in the video course Design Patterns in C# Made Simple, published at Udemy: 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: Beginning Object-oriented Programming with C# ► Collections and Generics in C# ► Making Your C# Code More Object-oriented ► Other courses at Pluralsight ► Other courses at Udemy ► Other videos on this channel you may be interested in watching: Using GitHub Copilot to Write Complex Code | Step-by-step Tutorial ► Coding with GitHub Copilot - Beginner to Master | VS Code Demo ► What is Covariance and Contravariance in C# ► How to Initialize a Clean Core Project with Entity Framework Core and Identity ► The Null Conundrum: A Guide to Optional Objects in C# ►










