Tags
Language
Tags
April 2024
Su Mo Tu We Th Fr Sa
31 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 1 2 3 4

Component-Based Rails Applications

Posted By: Grev27
Component-Based Rails Applications

Stephan Hagemann, "Component-Based Rails Applications"
English | ISBN: n/a | 2016 | PDF | 184 pages | 20 MB

What are component-based applications? And what is this book about?

Component-based applications show the single responsibility principle at work at all levels of an application. When implementing new features, the developers of these applications ask not only "what is the best place to put this"? but also "is that best place still good enough or do we need a new one"? In doing so they create pieces of code that exhibit high cohesion on their inside and low coupling on the outside.

In terms of Ruby, the first-class levels are method, class, and application. Along this continuum of increasing size, it becomes more difficult for developers to answer the question of single responsibility. What makes this even more challenging is that some of the frameworks we use, most notably Rails, value other principles more and thus take focus away from writing single responsibility pieces.

Another aspect to the difficulty of implementing component-based applications in Ruby is that one level has been very much overlooked due to a concept missing from the Ruby language: the package. Modules used as namespaces get close to the idea of a package, but don't provide another layer of visibility rules and thus fall short of being package equivalents.

Gems, used as packages and distributed as vendor code, as part of the application, turn out to be the closest thing to the idea of the package in Ruby. As such they impact the list of levels that single responsibility can be sought for: they add a level. That makes the list method, class, gem, and application. Because gems provide everything needed to simulate packages and because they are composable and distributable, here we will call them "components."

This book explores the many ways to use components, how to get there in the face of a classic Rails application, and all the steps along the way.