General Microservices Design Principles in brief

1. SOLID principle:

S single responsibility principle- there should never be more than 1reason for the class to change

O open-closed principle- objects should be open for extension and closed for modification

L Liskov substitution principle- we should be able to substitute child class with the base class and 

this should not alter the behaviour of a program 

eg. instead of having a square extend rectangle have shape interface with the area as an abstract method

I interface segregation principle. the interface should not have unnecessary abstract methods

D dependency inversion principle- auto wiring in spring boot

2. The DRY Principle: Don't Repeat Yourself

DRY stand for "Don't Repeat Yourself," a basic principle of software development aimed at reducing repetition of information. The DRY principle is stated as, "Every piece of knowledge or logic must have a single, unambiguous representation within a system."

3. KISS Principle: Keep It Simple, Stupid

The KISS principle is descriptive to keep the code simple and clear, making it easy to understand. After all, programming languages are for humans to understand — computers can only understand 0 and 1 — so keep coding simple and straightforward. Keep your methods small. Each method should never be more than 40-50 lines.

4. The Composition Over Inheritance Principle:

One should often prefer composition over inheritance when designing their systems.we should more often define interfaces and implement them, rather than defining classes and extending them.

5. Delegation principles:

Don't do all stuff by yourself, delegate it to the respective class. Classical example of delegation design principle is equals() and hashCode() method in Java.


source - various

Comments

Popular posts from this blog

Understanding and Avoiding Race Conditions in Java

The Interplay of Money and Risk

For Java