---
title: "Discussion on \"SOLID Principles in JavaScript\" | Hashnode"
description: "Discussion on \"SOLID Principles in JavaScript\". The SOLID principles are software design principles that help us understand how we can structure our code to be robust, maintainable, and flexible as much as possible.\nHere come the S.O.L.I.D. principles:\n\nS: Single Responsibility\n\nO: Open/Close\n\nL: ..."
url: "https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [SOLID Principles in JavaScript](https://blog.francescociulla.com/solid-principles-in-javascript?utm_source=hashnode&utm_medium=feed)

The SOLID principles are software design principles that help us understand how we can structure our code to be robust, maintainable, and flexible as much as possible. Here come the S.O.L.I.D. principles: S: Single Responsibility O: Open/Close L: ...

Sep 29, 2020 · 5 min read · blog.francescociulla.com  
Updated Apr 10, 2023  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#programming-tips](https://hashnode.com/tag/programming-tips)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)
-   [#coding](https://hashnode.com/tag/coding)
-   [#codenewbies](https://hashnode.com/tag/codenewbies)

## Written by

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

@FrancescoCiulla · Rome, Italy

  
[View profile](https://hashnode.com/@FrancescoCiulla)

Developer Advocate at daily.dev https://daily.dev

👋 Hi, I Am Francesco I am a Computer Scientist interested in Web3 and DevRel. I worked from 2017 to 2020 on the Copernicus project for the ESA European Space Agency as a Fullstack Developer. Docker Captain I have interviewed 195+ Developers on my YouTube Channel I am a Developer Advocate at daily.dev I have founded 4C, a community focused on Content Creation.

## Responses 15

Markdown supported · ⌘↵ to post

[Amitav Panda](https://hashnode.com/@Amitavpanda)

[Sep 7, 2023](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/64f9df59139d4c9cb61181fb)

Great Article Francesco!

[Himanshu Chauhan](https://hashnode.com/@Himanshu3)

[May 10, 2023](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/645af2fc9197834c2edbfa90)

Very informative. Thank you for sharing

[Nik Sumeiko](https://hashnode.com/@niksumeiko)

[Mar 11, 2021](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/604a6d76d00fe37d7cd08f43)

Hi Francesco, how you formulate and present information is inspiring. So simple and straightforward. I like it a lot and love to absorb such a material.

As regards SRP, both compositions under "No" and "Yes" examples are not violating the principle. They compose two things — validation and creation of the user. This function isn't an operation. It's a composition. Operations are `testForm()` and `createUser()`. They shall comply with SRP. And the composition composes operations, it's a control flow.

How about to rename `validateRequest()` function to something like `createValidUser()` in favor to clarify composition happening within?

What both examples violate is DIP, the last one from SOLID. Because they compose `testForm()` function and `createUser()` which become direct dependencies. We can't exchange them, if we need to run a different validation, for example.

To comply with DIP, we could inject them both into a composition.

```
createValidUser = (req: Request, validate: ValidateForm, createUser: CreateUser): void => {
  const { name, password, email } = req.body;

  if (validate(name, password, email)) {
    createUser(req);
  }

  throw new Error…
}
```

Voilà, now our composition `createValidUser()` function would depend on interfaces, not on implementations details.

When composition composes various operations it doesn't violate SRP. It contains a control flow of a program, which developers maintaining this code could clearly understand without looking at the implementation details of operations being composed.

[Your DevOps Guy](https://hashnode.com/@CodingLanguages)

[Oct 12, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f84b52c94b1323900e0db3d)

The visuals definitely help people get the gist of every principle. Then, coding becomes easy.

Good article, [Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)!

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

[Feb 4, 2021](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f84b52c94b1323900e0db3d#reply-601bff35072bc516ff6f23d1)

Thank you!

[Salil Kapoor](https://hashnode.com/@Salilkapoor)

[Oct 6, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7c4e8f1ee3b5689f326f9e)

Well, Explained! I read them many times but I wasn't clear about the last three. It's really well explained. Many thanks!

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

[Aug 8, 2022](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7c4e8f1ee3b5689f326f9e#reply-62f0e74de3a3793580e05be2)

Thank you Salil!

[Peter Thaleikis](https://hashnode.com/@spekulatius)

[Oct 5, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7ad69b9c3b6e41012180ca)

Awesome article! Thanks!

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

[Aug 8, 2022](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7ad69b9c3b6e41012180ca#reply-62f0e742e3a3793580e05bd6)

you are welcome Peter ....😂

[Maximilian Berkmann](https://hashnode.com/@berkmann18)

[Sep 30, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f74ac20b48bd01f3166054a)

Lovely article!

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

[Sep 30, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f74ac20b48bd01f3166054a#reply-5f74ba009e97481f1076fcf6)

Thank you Maximilian!

[Maximilian Berkmann](https://hashnode.com/@berkmann18)

[Sep 30, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f74ac20b48bd01f3166054a#reply-5f74bb7bb48bd01f31660617)

[Francesco](https://hashnode.com/@FrancescoCiulla) You're welcome :).

[Chris Bongers](https://hashnode.com/@dailydevtips)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f734e1ef955ec0a130f6596)

Awesome write-up Francesco! Love SOLID principles

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

[Sep 30, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f734e1ef955ec0a130f6596#reply-5f74ba09b48bd01f3166060c)

Thank you Chris!

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f73400bf955ec0a130f64d9)

Great Article [Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)!!! Good to see you here :)

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

[Aug 8, 2022](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f73400bf955ec0a130f64d9#reply-62f0e72edfc2b15565886361)

Thank you Apoorv...I am just a little late on this 😂

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)

[Aug 8, 2022](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f73400bf955ec0a130f64d9#reply-62f1017ddfc2b1556588698f)

Haha. No worries

[Tapas Adhikary](https://hashnode.com/@atapas)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f733298f955ec0a130f6351)

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla), Awesome writeup, and great content.

Question: Are the images snaps taken from the white-board or using a tool? They look awesome and very relevant to each of the sections. Nice work!

[Mohit Sehgal](https://hashnode.com/@mohitsehgal)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7316461d7a870a345b9af1)

What a start .. Loved it

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7316461d7a870a345b9af1#reply-5f7319e81d7a870a345b9b27)

Thank you Mohit! I will check your articles!

[Mohit Sehgal](https://hashnode.com/@mohitsehgal)

[Sep 30, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7316461d7a870a345b9af1#reply-5f74b0dfb48bd01f31660592)

Welcome [Francesco Ciulla](https://hashnode.com/@FrancescoCiulla) :)

[Shad Mirza](https://hashnode.com/@iamshadmirza)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7312991d7a870a345b9a7d)

Loved it.

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7312991d7a870a345b9a7d#reply-5f731a181d7a870a345b9b2c)

Thank you Mohd, really appreciated!

[Edidiong Asikpo (Didi)](https://hashnode.com/@didicodes)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7311511d7a870a345b9a56)

Fantastic and insightful article [Francesco Ciulla](https://hashnode.com/@FrancescoCiulla). Thanks for sharing.

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f7311511d7a870a345b9a56#reply-5f731a381d7a870a345b9b30)

Hey Edidiong! You have a different picture on Twitter but I recognize you! :)

Thank you so much!

[Sunil Kumar](https://hashnode.com/@sunilkumarc)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f730c2ef955ec0a130f601e)

Great article Francesco!

[Francesco Ciulla](https://hashnode.com/@FrancescoCiulla)

[Sep 29, 2020](https://hashnode.com/posts/solid-principles-in-javascript/5f73062cf955ec0a130f5fb2/comment/5f730c2ef955ec0a130f601e#reply-5f731a55f955ec0a130f6134)

Thank you Sunil and thanks for the following!
