Seeking God objects
Active Record is the largest part of Rails; its code base contains twice as many files (over 1,000) and lines of code (over 100,000) as the second largest, which is Action Pack. With that amount of machinery under the hood, it provides dozens of APIs for developers to use in their applications. As a result, models inherited from Active Record tend to carry many responsibilities, which we were trying to enumerate in the previous sections of this chapter. Such over-responsible Ruby classes are usually referred to as God objects.
From the code perspective, a lot of responsibility means a lot of lines of source code. The number of lines itself can’t be considered an indicator of unhealthy code. We need better metrics to identify good candidates for refactoring in our code base. The combination of churn and complexity has been proven to be such indicators.
Churn describes how often a given file has been modified. A high change rate could indicate a code...