-
Notifications
You must be signed in to change notification settings - Fork 2k
Complexity reduction #510
Complexity reduction #510
Conversation
|
👍 for reducing the complexity, 👎 on how it's done here. I don't think we want those factories beind part of the SDK API. |
|
Imo depends on "how the final developers should use the library", because if the @yguedidi what do you think about this? Of course no problem if I should change the system to private methods, the goal is the same. :) |
|
I think that any guessing should go in the master class, the easy to use starting point for developers, and any internal thing (or call it "advanced usage") should be type hinted. In the example of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this condition can be simplified as 'stream' === $handler, with the same behavior, but a smaller cyclomatic complexity when computing it: you will only have 2 cases for this condition (the stream string vs anything else) instead of having 3 cases (the stream string vs any other string vs any other type)).
|
@yguedidi having separate factories makes sense at least for the guessing of the best implementation, as it makes the logic usable even when you use directly the lower-level API (instead of having to duplicate the logic). |
|
I'm down with the factories. There was another guy I was showing the source code to at a recent PHP conference who suggested using factories as well.
@stof What convention are you referring to? On "php the right way" the example uses a |
|
@stof first of all: thank you for all those corrections, applied and now it should be ok. PS: @gfosco I'm waiting your 👍 or 👎 before going ahead with tests and documentation. |
|
You have my 👍 😃 |
|
@EmanueleMinotto I would use |
It is far. the only interface you could extract in your current implementation would be |
|
👍 No need to worry about docs. All changes are internal and won't the public API unless we wanted to document the factories. But I think it might confuse newbies so if we decide to document it, it should probably be added to the reference only and not part of the "getting started" or anything. Thanks for helping clean up the codebase @EmanueleMinotto! |
|
my pleasure @SammyK :) |
|
Cool! 👍 |
To solve the
Facebook\Facebookconstructor complexity problem (defined on Scrutinizer), I've splitted it into different factories:Facebook\PseudoRandomString\PseudoRandomStringGeneratorFactoryFacebook\HttpClients\HttpClientsFactoryFacebook\PersistentData\PersistentDataFactoryThis should also allow you to move different detection logic into these factories and keeping some other classes' focus on their behaviour and responsabilities.
Another small change I did is the removal of an
\InvalidArgumentExceptionexception replicating a setter logic (afaik).Of course I'll add related tests and documentation if the RFC is accepted.