My main concern is to find a way to avoid to add every new feature as a method in the User model, because it can become huge.
For example
$user->like($post)
$user->subscribe($post)
And the list goes on.
I watched a video where Adam Wathan was explaining that a method name should describe
-
what you can do to the object
-
NOT what an object can do
Taking the aforementioned examples, according to Adam
$post->like($user)
$post->subscribe($user)
And I have to say that this looks nice, and it helps to prevent making the User model a god object.
However, there are cases that this approach can be confusing.
For example, when a user wants to follow another user
$John->follow($doe);
In this example, following Adam's approach, Doe started following John and not the other way around, which is confusing.
Another approach can be to use past tense and maybe even use by in method names to make it even more clear, for example
$post->liked($user);
$post->likedBy($user);
$John->followed($doe);
This can still be confusing so maybe using also the by word would be more clear.
$John->followedBy($doe);
What are your thoughts on this ?