You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 via Cog\Contracts\Love\Reacterable\Models\Reacterable interface.
Cog\Contracts\Love\Reactant\Models\Reactant is connected with polymorphic models via Cog\Contracts\Love\Reactable\Models\Reactable interface.
Rules
When the base word is a complete and recognizable word, you will usually use -able.
When the base word ends in -e, you should remove ending -e, then add -able. Leave the -e when the word ends in -ce or -ge.
If you must double the final consonant of the base word or change the final -y to -i, add -able.
In general, -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:
not all words has related words with -able suffix (in that case I just ignore that and add this word to my vocabulary);
some words has related words with -able suffix, but they are writing a bit different, for example for word Reactant there is no word Reactantable, but Reactable 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 via Cog\Contracts\Love\Reacter\Able\Models\AbleInterface interface.
Cog\Contracts\Love\Reactant\Models\ReactantInterface is connected with polymorphic models via Cog\Contracts\Love\Reactant\Able\Models\AbleInterface interface.
Right now traits has methods bootReactable & bootReacterable, but with new implementation both of the traits will have bootAble methods, will it work if model uses both of the traits?
This concept could be extracted to Cog\Laravel\Able package.
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:
This discussion was converted from issue #78 on October 03, 2020 06:26.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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