Sunfox


Journal

Archives de 2020

Actor

18 avril 2020

I created a Ruby gem called Actor. It helps you harmonize your application’s service objects.

Service Objects?

Service objects are a way of making your web applications grow in complexity while keeping your controllers and models thin. For that you’d create classes that represent your actions, for example, CreateComment, PlaceOrder, DestroyUser, etc.

At the start, these actions might hold very little code and look a lot like a regular controller. But as your app grows, you’ll realize that something simple like creating a comment can turn into a serie of actions:

  • creating a record in the database,
  • checking the contents for spam or duplicates,
  • updating counters and cache keys,
  • sending email or Slack notifications,
  • logging the action to another system,
  • triggering a job to translate the contents,
  • etc.

These actions deserve a way of being represented as first-class citizens in your application. That’s where actor comes into play!

Suite de l’article…

👨🏻‍🦰 Sunny Ripert

est un développeur web vivant à ParisContactArchives

Textes et contenus sous licence Creative Commons.