Design Principle:
The Design principles are provided with some high-level guidelines or you can say mechanisms to make the software designs more understandable, flexible as well as maintainable. They (i.e. Design Principles) do not provide any implementation and also they are not bound to any programming languages. So, you can use design principles irrespective of the Programming Languages. Example: SOLID (SRP, OCP, LSP, ISP, DIP) Design Principles.
For example, the Single Responsibility Principle (SRP) states that a class should have only one reason to change. This is the high-level statement that we need to keep in mind while designing the classes for our application. The SRP does not provide any specific implementation steps but it’s up to us how we implement the Single Responsibility Principle in our application.
Design Pattern:
The Design patterns are reusable solutions to the problems that we encounter in our day-to-day programming. They are basically used to solve the problems of object generation and integration. For example, if you want to create a class that can have only one instance for the entire application then you can use the Singleton design pattern which ensures that a class has only one instance for the entire application and provides a global point of access to it. There are so many design patterns that are tested by others and are safe to follow. For example. Gang of Four Design Patterns: Abstract Factory, Factory, Singleton, etc.
Once you understand the difference between Design Patterns and Design Principles, let’s understand the terms IoC (Inversion of Control), DIP (Dependency Inversion Principle), DI (Dependency Injection) Design pattern, and IoC Containers. The following diagram gives you a clear idea of whether they are principles or patterns or frameworks.
Once you understand the difference between Design Patterns and Design Principles, let’s understand the terms IoC (Inversion of Control), DIP (Dependency Inversion Principle), DI (Dependency Injection) Design pattern, and IoC Containers. The following diagram gives you a clear idea of whether they are principles or patterns or frameworks.
As principles, they only provide some high-level guidelines or mechanisms to develop software applications but they do not provide any specific implementation details. Dependency Injection is a design pattern whereas IoC Containers are frameworks. Let’s have a look at each term before going into details.Inversion of Control (IoC) in C#:
The main objective of Inversion of Control (IoC) in C# is to remove the dependencies (remove tight coupling) between the objects of an application which makes the application more decoupled and maintainable.
The IoC Design Principle suggests the inversion of various types of controls in object-oriented design to achieve loose coupling between the application classes. Here, control means any extra responsibilities a class has other than its main or fundamental responsibility. For example, control over the flow of an application, control over the dependent object creation, etc.
No comments:
Post a Comment