Skip to main content

SOLID Principle (software design principles)

Code Smell:
  • Rigidity -hard to modify
  • Fragility - any change make code unstable or bug prone 
  • Immobility -components can not be reused in other system
  • Viscosity - single change forces to change lot of places
  • Needless complexity - excessive point of extension
Major issue with code smell is Tight Coupling 

SOLID principles are introduced to reduce code smells, they are:

  • S  - Single Responsibility Principle
  • O - Open Close Principe (Open for extension and Close for modification)
  • L - Liskove substitute principle (replace the object/instance of a parent class with an object/instance of the child class, without affecting the behavior of the base class instance)
  • I - Interface Segregation Principle - Clients should not be forced to implement any methods they don’t use. Rather than one fat interface, numerous little interfaces are preferred based on groups of methods with each interface serving one submodule.
  • D - Dependency Inversion Principle (DIP)- high-level modules/classes should not depend on low-level modules/classes. Both should depend upon abstractions.

Comments

Popular posts from this blog

API Basics

 

Algorithm solving Common Patterns & Techniques

  These are targeted data manipulation strategies used to handle arrays, strings, and linked lists efficiently. Two Pointers : Uses two reference pointers to iterate through a data structure simultaneously, typically from opposite ends or at different speeds (Fast & Slow pointers). Sliding Window : Maintains a subset of data (a "window") over a sequential structure to track running statistics without recalculating the whole set. Prefix Sum : Pre-computes and stores cumulative sums of an array to allow for \(O(1)\) constant-time range sum queries. Dynamic Programming (DP ): Dynamic programming is an optimization technique used to solve problems by breaking them down into simpler subproblems and storing the results of these subproblems to avoid redundant computations. It is particularly effective for problems exhibiting overlapping subproblems and optimal substructure. Greedy Algorithm Breadth-First Search (BFS) / Depth-First Search (DFS) : Systematic graph and tree travers...