Reader small image

You're reading from  Clean Code in PHP

Product typeBook
Published inOct 2022
PublisherPackt
ISBN-139781804613870
Edition1st Edition
Tools
Right arrow
Authors (2):
Carsten Windler
Carsten Windler
author image
Carsten Windler

Carsten Windler is a Lead PHP engineer at Plan A.
Read more about Carsten Windler

Alexandre Daubois
Alexandre Daubois
author image
Alexandre Daubois

Alexandre Daubois is a Symfony Developer at SensioLabs, the company that created Symfony.
Read more about Alexandre Daubois

View More author details
Right arrow

Separating responsibilities

Let’s see what the separation of responsibilities in the code consists of, to make it cleaner, understandable, maintainable, and extensible. This is the first point of the SOLID principles. In the second chapter, this is how we defined the principle of single responsibility: “It means that a class in your code must respond to only one task.

As a reminder, SOLID is a set of known clean-code rules that, when applied together, will make your code much clearer and more accurate. Rather than trying to follow the five principles described by each of the SOLID caps to the letter, it is more important to have a global idea of all this in mind when you code.

The first step to respect this is, in fact... naming, as we just saw! Indeed, by naming a class properly, clearly, and, above all, precisely, you are already making sure that it doesn’t become a mess where you put a little bit of everything that you can think of. And it is for...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Clean Code in PHP
Published in: Oct 2022Publisher: PacktISBN-13: 9781804613870

Authors (2)

author image
Carsten Windler

Carsten Windler is a Lead PHP engineer at Plan A.
Read more about Carsten Windler

author image
Alexandre Daubois

Alexandre Daubois is a Symfony Developer at SensioLabs, the company that created Symfony.
Read more about Alexandre Daubois