Usually I use nouns when I give names to my classes. I gave a noun derived from a verb like 'worker' or 'purchaser' as name for my service objects. During a code review it was said that it is common to gave verbs as names for service objects like 'work' 'purchase'.
Which direction should I follow?
Here is another oppinion against verbs:
Mostly it doesn't make sense from a standpoint of clarity and natural language to use verbs. Let's say you have model Product and you want a service object that will handle pricing on some complex criteria (geolocation, color, shipping, moonphase, etc). It would be a good candidate for a service object ProductPricingService. You wouldn't just call it Price or Pricing. First of all it's ambigious. Pricing of what? Products that you sell? Pricing you get from vendors? Pricing of gas today? And if you were to argue that this Service object could be used by many models, then you are defeating the purpose of Service Object. I'm exaggerating of course. But the whole point is to create clear and maintainable code. So while you can save some keystrokes by naming it Price, it's much more clear to another person ( and you in 5 months) if you name it ProductPricingService.
Here is an oppinion against deverbal nouns
You can use something like InvoiceFinder instead of FindInvoice, but I found out that putting the action at the end led to awkward named classes, so putting the verb at the beginning made them cleaner.
I think your original one, using deverbal nouns makes more sense. You should use verbs for method names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With