jeudi 28 mars 2019

Is there a better way to implement dependencies?

Below is my use case:

Employee Management is a separate C# class library project. And there is a setting for Employee Management at application level. It means there is a global Boolean variable isEmployeeManagement

If the variable is true, then all the code related with Management used across whole application should get executed for e.g.

IEmployeeManagement.AddUser();
IEmployeeManagement.DeleteUser();

But if the setting is false then; the below lines should not through any exception. One of the approaches I thought of is like checking the condition.

If (isEmployeeManagement)
  IEmployeeManagement.AddUser();

But I want to achieve this using Interfaces without putting any code in the condition. So if the setting is false, the above code should not through any error.

Appreciate if you could help me with the implementation.

Aucun commentaire:

Enregistrer un commentaire