RailsConf 2023 - Rails as a piece of birthday cake by Vladimir Dementyev

Explore the importance of abstraction in Rails development, using a cake analogy to illustrate the concept of layers, responsibilities, and hiding complexity, and learn how to apply it effectively to create maintainable and scalable code.

Key takeaways
  • Rails is often poorly abstracted, leading to messy code.
  • A good abstraction should separate concerns and follow a single responsibility principle.
  • Abstraction layers can be identified, and described as encapsulation and hiding complexity.
  • Service objects can be an issue, as they can lead to over-engineering or too many responsibilities.
  • Presentation layer should be separated from infrastructure layer.
  • Form objects can be a good abstraction, but they may require more complex setup.
  • Rails has its own heap of abstractions, such as Active Model and Active Record.
  • Abstraction should not be introduced for the sake of abstraction, but for solving specific problems.
  • Scaling abstraction layers can lead to more complex, less maintainable code.
  • A cake is a good analogy for abstraction, as it has many layers, each with its own responsibility.
  • The presentation layer should be simple and coherent.
  • Avoid repeating functionality in multiple places.
  • A service object is not a good abstraction.
  • There should be few abstraction layers, each with its own responsibility.
  • Complexity should be hidden through abstraction.
  • Code should be maintainable and easy to read.
  • Abstraction should be defined by the problem it solves, not the number of layers.
  • There is no universally accepted definition for service objects.
  • Abstraction should not be artificial, but solving specific problems.
  • The cake analogy of abstraction is helpful.