DEV Community

Discussion on: Code Smell: No AND in Function name

Collapse
 
napicella profile image
Nicola Apicella

Hi! Thanks for sharing.

SRP seems so easy to understand, but in fact it is not.
Toy examples are good to make a point, but hardly match the complexity of a real system.
So even in your example, the function which makes the breakfast is gonna call all three the function you defined (eggs, tea, flour).
Does that respect the SRP? It depends on the context.

Alrought having 'And' in a function name is a smell, what about the same one renamed without the 'And'?

The definition of SRP itself causes these kind of conflicts, which is why I use a different one, which takes into account what is the effect of SRP:
Functions X respects SRP if it has only one reason to change.