Sign in
Log inSign up
Francesco Ciulla

397 likes

·

7.4K reads

29 comments

Tapas Adhikary
Tapas Adhikary
Sep 29, 2020

Francesco Ciulla, 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!

9
·
Nik Sumeiko
Nik Sumeiko
Mar 11, 2021

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.

9
·
Deactivated User
Deactivated User
Deactivated User
Sep 29, 2020

I once took a course on Design Principles, dumped it before I could finish off the second module, which was about the SOLID principle.

Wish I had seen this. Amazing write-up, Francesco!

7
·
·1 reply
Francesco Ciulla
Francesco Ciulla
Author
·Sep 29, 2020

Thank you Gyen! I hope it was useful as a refresher!

2
·
Sunil Kumar
Sunil Kumar
Sep 29, 2020

Great article Francesco!

5
·
·1 reply
Francesco Ciulla
Francesco Ciulla
Author
·Sep 29, 2020

Thank you Sunil and thanks for the following!

2
·
Shad Mirza
Shad Mirza
Sep 29, 2020

Loved it.

3
·
·1 reply
Francesco Ciulla
Francesco Ciulla
Author
·Sep 29, 2020

Thank you Mohd, really appreciated!

1
·
Mohit Sehgal
Mohit Sehgal
Sep 29, 2020

What a start .. Loved it

2
·
·2 replies
Francesco Ciulla
Francesco Ciulla
Author
·Sep 29, 2020

Thank you Mohit! I will check your articles!

1
·
Mohit Sehgal
Mohit Sehgal
Sep 30, 2020

Welcome Francesco Ciulla :)

1
·
Apoorv Tyagi
Apoorv Tyagi
Sep 29, 2020

Great Article Francesco Ciulla!!! Good to see you here :)

2
·
·2 replies
Francesco Ciulla
Francesco Ciulla
Author
·Aug 8, 2022

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

·
Apoorv Tyagi
Apoorv Tyagi
Aug 8, 2022

Haha. No worries

·
Edidiong Asikpo (Didi)
Edidiong Asikpo (Didi)
Sep 29, 2020

Fantastic and insightful article Francesco Ciulla. Thanks for sharing.

1
·
·1 reply
Francesco Ciulla
Francesco Ciulla
Author
·Sep 29, 2020

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

Thank you so much!

3
·
Chris Bongers
Chris Bongers
Sep 29, 2020

Awesome write-up Francesco! Love SOLID principles

1
·
·1 reply
Francesco Ciulla
Francesco Ciulla
Author
·Sep 30, 2020

Thank you Chris!

·
Maximilian Berkmann
Maximilian Berkmann
Sep 30, 2020

Lovely article!

1
·
·2 replies
Francesco Ciulla
Francesco Ciulla
Author
·Sep 30, 2020

Thank you Maximilian!

·
Maximilian Berkmann
Maximilian Berkmann
Sep 30, 2020

Francesco You're welcome :).

1
·
Peter Thaleikis
Peter Thaleikis
Oct 5, 2020

Awesome article! Thanks!

·
·1 reply
Francesco Ciulla
Francesco Ciulla
Author
·Aug 8, 2022

you are welcome Peter ....😂

·
Salil Kapoor
Salil Kapoor
Oct 6, 2020

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

·
·1 reply
Francesco Ciulla
Francesco Ciulla
Author
·Aug 8, 2022

Thank you Salil!

·
Your DevOps Guy
Your DevOps Guy
Oct 12, 2020

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

Good article, Francesco Ciulla!

·
·1 reply
Francesco Ciulla
Francesco Ciulla
Author
·Feb 4, 2021

Thank you!

·
Himanshu Chauhan
Himanshu Chauhan
May 10, 2023

Very informative. Thank you for sharing

·
Amitav Panda
Amitav Panda
Sep 7, 2023

Great Article Francesco!

·