Interview: SOLID Principles

vishal gupta
Oct 28, 2020

--

  1. Single Responsibility — A class should have a single responsibility.

This principle aims to separate behaviours so that if bugs arise as a result of your change, it won’t affect other unrelated behaviours.

2. Open-Closed : Software entities(Classes, modules, functions) should be open for extension, not modification.

Changing the current behaviour of a Class will affect all the systems using that Class.

If you want the Class to perform more functions, the ideal approach is to add to the functions that already exist NOT change them.

3. Liskov Substitution Principle: A sub-class must be substitutable for its super-class.

When a child Class cannot perform the same actions as its parent Class, this can cause bugs.

This principle aims to enforce consistency so that the parent Class or its child Class can be used in the same way without any errors.

4. Interface Segregation: Clients should not be forced to depend on methods that they do not use

5. Dependency Inversion
- High-level modules should not depend on low-level modules. Both should depend on the abstraction.
This principle aims at reducing the dependency of a high-level Class on the low-level Class by introducing an interface.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

vishal gupta
vishal gupta

Written by vishal gupta

Software Architect, Author, Trainer

No responses yet

Write a response