clean-code-php icon indicating copy to clipboard operation
clean-code-php copied to clipboard

"Use default arguments instead of short circuiting or conditionals"

Open danilyer228 opened this issue 3 years ago • 2 comments

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".

danilyer228 avatar Apr 28 '21 03:04 danilyer228

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.

peter-gribanov avatar Apr 28 '21 07:04 peter-gribanov

@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.

danon avatar Jun 15 '22 13:06 danon