This class teaches you the SOLID design principles using the C# programming language. The SOLID principles include:
• Single Responsibility Principle (SRP)
• Open-Closed Principle (OCP)
• Liskov Substitution Principle (LSP)
• Interface Segregation Principle (ISP)
• Dependency Inversion Principle (DIP)
In this class you’ll learn about these principles and see sample code that teaches you how to spot when these principles are not adhered to and how to fix the situation.
This class is part of a broader “Design Patterns in C# and .NET” curriculum.
Skills in this Class
• MOBILE DEVELOPMENT
• DESIGN PATTERNS
Projects & Resources
In our discussion of the Open-Closed Principle, we looked at the Specification pattern and how that can be used to achieve a situation where different ways of filtering items are extended through inheritance.
You are asked to further extend this model, implementing some or all of the following features:
• Allow searching by multiple criteria directly in the API. I want to be able to filter by, say, both size and color with succinct API syntax. (Hint: consider making APIs that take params ISpecification<>).
• Allow defining flexible criteria. For example, if a Product has a Price, create filtering specifiers for searching for products with price less than X or greater than Y.
• Introduce context-sensitive search. For example, say only Premium customers can search for Premium products — how would you implement the filtering function when context needs to be taken into account? Try making this as generic as possible.
Also, consider making more succinct APIs that would allow you to filter items without working with IFilter/ISpecification objects directly. Ideally, I’d like to be able to write:
products.Filter(Color.Green && Size.Large)
And produce a meaningful result set. How can this be accomplished?
Bonus round: suppose that, somewhere in your program, you need a listing of all criteria that can be used for filtering. How would you make associations between, say, a SizeSpecification and Size? How would you programmatically find all possible criteria at compile time (to, e.g., show on a webpage)? What if you wanted to know these criteria at compile time — how would you do this? (hint: code generation)
Created by – Dmitri N., Quantitative Finance Professional
Language – English
Released – 2019
Size: 211.87 MB