Skip to main content

Posts

Showing posts with the label DI/ IOC

Inversion of control - Part 1

When an object of a type depends on an object of another type we say that the types are coupled. This is because change in one can lead to a change in second. This will hamper the extensibility and modification in design. In a more complex system lot of classes interact with each other and this will lead to a very brittle design. Let's take an example:    class Program     {         static void Main(string[] args)         {             List<Employee> employees = new List<Employee>();             EmployeeController employeeController = new EmployeeController();             employees = employeeController.GetAllEmployees();         }     } Program depends on EmployeeController to fetch Employee(s).  Inversion of control Logically Inversion means rearrangement. ...