Able interfaces v1 #78
Unanswered
antonkomarev
asked this question in
RFC
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Notice: This is just a concept for the future, it doesn't mean it would be 100% implemented. Sharing my thoughts with community to receive feedback.
Current implementation
Cog\Contracts\Love\Reacter\Models\Reacter
is connected with polymorphic models viaCog\Contracts\Love\Reacterable\Models\Reacterable
interface.Cog\Contracts\Love\Reactant\Models\Reactant
is connected with polymorphic models viaCog\Contracts\Love\Reactable\Models\Reactable
interface.Rules
-able
.-e
, you should remove ending-e
, then add-able
. Leave the-e
when the word ends in-ce
or-ge
.-y
to-i
, add-able
.-ible
is less common and the base word is not a complete and recognizable word.However, there are some exceptions from these rules.
Motivation
Pattern is simple - just add
able
to model name and you'll get polymorphic model interface name.But there are exceptions:
-able
suffix (in that case I just ignore that and add this word to my vocabulary);-able
suffix, but they are writing a bit different, for example for wordReactant
there is no wordReactantable
, butReactable
exist.Idea
Polymorphic model contract must have
Able
class name and be inside of the namespace of the model to which access is providing. There is no need to have more than one entry point for accessing model methods.Cog\Contracts\Love\Reacter\Models\ReacterInterface
is connected with polymorphic models viaCog\Contracts\Love\Reacter\Able\Models\AbleInterface
interface.Cog\Contracts\Love\Reactant\Models\ReactantInterface
is connected with polymorphic models viaCog\Contracts\Love\Reactant\Able\Models\AbleInterface
interface.System Design
Things to consider
Right now traits has methods
bootReactable
&bootReacterable
, but with new implementation both of the traits will havebootAble
methods, will it work if model uses both of the traits?This concept could be extracted to
Cog\Laravel\Able
package.We can create
AbstractAble
class with:Alternative
There is another one possible concept on my mind. We can ignore the correctness of spelling by adding capitalized
*Able
suffix to the names and it will be perceived as 2 worded names:Cog\Contracts\Love\ReacterAble\Models\ReacterAbleInterface
Cog\Contracts\Love\ReactantAble\Models\ReactantAbleInterface
It will be very useful for such names like
Individual
which has-able
suffixed form asIndividable
.Beta Was this translation helpful? Give feedback.
All reactions