دانلود کتاب Component-Based Rails Applications
by Stephan Hagemann
|
عنوان فارسی: برنامه های ریلی مبتنی بر کامپوننت |
دانلود کتاب
جزییات کتاب
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.