Cocoa provides a basic infrastructure for model value validation.
However, it requires you to write code for all the constraints you want to apply.
These principles include separation of concerns, loose coupling, scalability and fault-tolerance.
However, given the lack of a precise and universal definition for microservices, it becomes clear that there is no single recipe for implementing a microservices system successfully.
Only incrementally better than cluttering controllers with domain logic, they usually represent a failure to apply the Single Responsibility Principle (SRP).
“Anything related to what a user does” is not a responsibility. Active Record classes handle persistence, associations and not much else. Objects that are inherently responsible for persistence become the interface. As you add more intrinsic complexity (read: features!
We encountered a number of anti-patterns on a number of projects we worked on, building systems that can be characterised as ‘microservices’.
Given their pervasive nature, they should be considered and understood, ideally in the early stages of a project, in order to be mitigated and avoided.
Sure, it looks cleaner at the surface, but the junk drawers actually make it harder to identify and implement the decompositions and extractions necessary to clarify the domain model. Value Objects are simple objects whose equality is dependent on their value rather than an identity. are examples from Ruby’s standard library, but your application can (and almost certainly should) define domain-specific Value Objects as well.
Refactor to break them down and spread out the logic evenly.