MVC Asp Net 6 System Design

1. Try to design your codebase to be Type Free, agnostic by utilizing Polymorphism.
   - Use Base Classes when possible, this makes it really helpful to customize or include another object in one single class logic.
   - The best way to define Interfaces are :

        - Create a base Interface IMyLovelyBaseInterface<T> where T : class{
             myRequiredLovelyFunction();
           }
        - then create specific type Interface and enherit the Base Interface like so:

           interface IMyOwnInterface : IMyLovelyBaseInterface<MyLovedlyTypeOfClass>{
             myFunction(); //This interface will contain all functions defined in the base interface.
           }

[NB] You can register your IMyOwnInterface and it's consuming repository in a Startup.cs like so:
        services.AddScopped<IMyOwnInterface,MyConsumingRepository>(); // Enjoy the Dependency Injection the DI Container provides.


Write an Article
#System Design #programming tools System Design published
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.


© 2022 - ErnesTech - Privacy