Go back to the blog

AMA: How to deal with complex business logic?

Organizing a large and busy application is a non-trivial task. Over the years we started applying the following strategies:

Reused logic goes into concern files, as it is a plug-and-play logic that requires a similar data model.

Business logic that provides clear functionality goes into specialized controllers, e.g. SessionsController, PaymentsController, ConfirmationsController, etc. that relies on a limited set integration in the application and thus provides a clear functionality module.

Integration logic using multiple subsystems goes into service objects, e.g. AccountCreationService, AccountRemovalService, which rely on a wide variety of internal objects and functionalities (models, mailers, 3rd party integrations) and have a "macro" feel.

We hope that helps you to organize your app!

This is a question asked during an AMA (Ask Me Anything) session — follow the blog to keep up with the common engineering questions and answers, or join our free mentoring platform!

Read more articles like this one:

Ruby on Rails 8 Code Architecture 5