3 ms·
Here's a heuristic: Verbs don't belong in class names. Maybe in module names. But even then. Any good counterexamples?
by phillmv 14y ago
Here's a heuristic: Verbs don't belong in class names. Maybe in module names. But even then.
Any good counterexamples?
- karmajunkie 14y agocommand objects are usually named as imperative verbs.
- hcarvalhoalves 14y agoYes, I agree. Naming a class with a verb is a good signal that you're trying abstract the wrong thing. If you want to move certain responsibilities outside the object, you make a "Handler" class that is in charge of that behavior and listen to appropriate events. How I would approached it: refactor the logic in FacebookHandler/TwitterHandler, make the Comment object send an event when one is added, make the handlers listen and do their magic. Implement a common interface for grabbing the Tweet/FB post text. Done. Now all your models can post to Twitter/FB with a common interface. EDIT: For clarity
- Smudge 14y agoI stated this in a different comment, but, to repeat myself, I would call this class by what it is ("CommentPoster") instead of what it does ("PostComment"). CommentPoster.new(@comment).post Looks slightly better to me.