piotrplenik / clean-code-php

:bathtub: Clean Code concepts adapted for PHP
MIT License
12.28k stars 2.28k forks source link

"Use default arguments instead of short circuiting or conditionals" #189

Open danilyer228 opened 3 years ago

danilyer228 commented 3 years ago

https://github.com/jupeter/clean-code-php#use-default-arguments-instead-of-short-circuiting-or-conditionals

I think, it's must be in "Functions" section and renamed with something like "Don't pass NULL arguments".

peter-gribanov commented 3 years ago

I agree that this section should be moved to the Functions section. But over the name of this section, i would have thought more. This section is about how to properly use default values for arguments, not how not to pass NULL.

danon commented 2 years ago

@peter-gribanov Not sure this is actually a useful tip.

First of all, I'm not actually sure that default arguments (or optional arguments) are a good design, by that's my opinion.

Regarding "clean code php", notice that when using polymorphism, you'd have to declare the default value multiple times (in the interface, and then in the implementations).

I really think this tip isn't helpful.