Design Patterns (C#)
This topic is very interesting because it teaches you how to think in an Object Oriented way. Developers tend to say that Design Patterns come naturally, but on the other hand, developers should be aware of good Design Architecture that saves time and money (less expensive to maintain).
- It is always good to decouple application and limit dependencies on other application, for example, build an application independent from their others. We see this kind of implementation when the developer includes several projects in one Visual Studio project and then bind each project by including references to others. Brilliant!!
- Experienced Developer once said that the way you determine if the System Architecture is good or not is observing when there is a Software Change Request. If a Developer has to go make a change in Four other places instead of One or Two then there is a problem.
RIP Design patterns (Replace IF statement with Polymorphism)
- One way to solve this problem is by creating one base class and let other Middle Layer Classes inherit from the base class (Polymorphism). It is overly stated that the best of Object Oriented Programming is Polymorphism, change that happens in one place does affect that other part of the Software.
- The other way you would avoid instantiating classes or strongly types Class Object is by creating a Factory Class (Why because it creates things.)
Simple Factory Patterns Design
The Factory Class will be responsible for Object creation and it should be Static. The Factory class should only create a new object and should eternity the parent class that is mainly in a third-party application. It should return a base class if someone in the future needs to add another type of an object they will be able to do so in one place.
Lazy Loading Design Patterns
- It is advisable to use libraries that exist and not start coding from scratch, with Lazy Loading implement Dot Net Lazy Loading library.