What are Design Principles?
Design principles provide blueprints for designing software programs from a high level abstraction perspective. These principles are not language specific and generally do not provide any implementation guidelines.The most popular design principles are represented b the acronym SOLID. The design principles are as explained below:
SRP; The Single Responsibility Principle - any given class must perform one and only one function
OCP; The Open Closed Principle - the behaviour of a class should be able to be extended without any need for the class to be modified
LSP; The Liskov Substitution Principle - derived classes must be able to be used as substitutes for their base classes
ISP; The Interface Segregation Principle - interfaces must be client specific
DIP; The Dependency Inversion Principle - dependency should be based on abstractions and not on any concrete implementations
What are Design Patterns and how is it different from Design Principles?
Design Patterns on the other hand provides a much more low-level abstraction approach to solving object-oriented design problems. Design Patterns are much more specific in suggesting a specific way of implementing a solution for a given object-oriented software program. Some common design patterns are;
1. Abstract Design Factory Design Pattern - An interface will be responsible for creating a factory of related objects without explicitly specifying their classes
2. Factory Design Pattern - Objects are created without revealing their creation logic to the client
3. Singleton Design Pattern - A single class is responsible for creating objects while ensuring that only a single object is created.
4. Command Design Pattern - A data driven design pattern where a request is made under an object as command and passed to an invoker object which looks for the appropriate object to handle the command.
Leave a comment below if you found this helpful. Happy Learning!