Closed antonkomarev closed 5 years ago
actAs
prefix$user->actAsLoveReacter()->reactTo($article, 'Like');
act
prefix is redundant because not all the methods will be actions. For example: $user->actAsLoveReacter()->isNull()
Don't use it.
Method should have as
prefix. Treat User model as Reacter.
$user->asLoveReacter()->reactTo($article, 'Like');
User as love reacter react to article with like
$user->registerAsLoveReacter()
$user->isRegisteredAsLoveReacter()
Don't want to use it because this prefix used in other languages in other cases.
Usually in Java & C# as
performs a cast; the same reference passed in is returned behind the "mask" of a different type. Expected that method return a potentially different view of the source. And we are returning completely different class: instead of Reacterable
we will return Reacter
model encapsulated in ReacterFacade
.
Method should have aka
prefix. User also known as Reacter.
$user->akaLoveReacter()->reactTo($article, 'Like');
User also known as love reacter react to article with like
Also known as
contains as
word which uses in:
$user->registerAsLoveReacter()
$user->isRegisteredAsLoveReacter()
Don't use it in favor of via
prefix.
Method should have as
prefix and Facade
suffix.
$user->asLoveReacterFacade()->reactTo($article, 'Like');
as
in:
$user->registerAsLoveReacter()
$user->isRegisteredAsLoveReacter()
Don't use it.
It's better than variant 2 because asLoveReacterFacade
will return ReacterFacade
of the Love package. But it wouldn't expose that in fact we are not dealing with user model anymore, but with Reacter.
Method should have get
prefix and Facade
suffix.
$user->getLoveReacterFacade()->reactTo($article, 'Like');
Don't use it.
Method should have via
prefix. By way of Reacter.
$user->viaLoveReacter()->reactTo($article, 'Like');
User by way of love reacter react to article with like
Use it.
Implemented in v7.0 release.
Since package API is strict typed its might be harder to use and couple your application with the package subsystems. Developers will pass to the
reactTo
method reactable instance and string value of reaction type name:->reactTo($comment, 'Like')
Facade design pattern to the rescue. Not the same as Laravel Facades (which act as "static proxies").
These facades will replace experimental global
Cog\Laravel\Love\Facades\Love
facade.Facade concept
Facade
shields developers from the complex details of the system and provides them with a simplified view of it which is easy to use. It also decouples the code that uses the system from the details of the subsystems, making it easier to modify the system later. It decreases maintenance cost, but adds additional layer of code & decreases runtime performance.Reacter Facade
User via
Reacterable
trait will have additional method which will provide simpler access toReacter
model methods. This method returnsFacades\Reacter
class which hide internal complexity behind a single interface that appears simple from the outside. Method will havevia
(by way of) prefix.Usage
Instead default strict typed Reacter model calls:
Facades\Reacter
class has simpler interface:Under the hood it will resolve Reactant model from
$comment
&ReactionType
from the string name and call strict typed method.Reactant Facade
Comment via
Reactable
trait will have additional method which will provide simpler access toReactant
model methods. This method returnsFacades\Reactant
class which hide internal complexity behind a single interface that appears simple from the outside. Method will havevia
(by way of) prefix.Usage
Instead default strict typed Reactant model calls:
Facades\Reactant
class has simpler interface:Under the hood it will resolve Reacter model from
$user
&ReactionType
from the string name and call strict typed method.Naming
Facades\Reacter
&Facades\Reactant
instantiation methods name candidate variants described in comments below.