Short Notes
April 18th, 2024

Service Objects and Naming in Ruby

In OOP (maybe in functional, too - but I don't have the same years of experience with functional), naming objects is hard. 

Naming a collection of objects that should do something together is harder too. 

Just one exanmple when there are multiple objects that needs to be coordinated in a specific sequence: 

  • Is there another object on a different level that should compose them?
  • If so what is that object called?
  • Does that name exist in the business domain, or is it a code pattern?

If such object can be found and properly named I would of course prefer using that object that will compose the others. 

But if the name will feel forced and sound like something that I will probably not think to grep when doing debugging, I prefer a consistent service object pattern instead of bad naming or inconsistent naming.