title |
---|
Ruby Science |
Ruby on Rails is more than 15 years old and its community has developed a number of principles for building applications that are fast, fun and easy to change: Don't repeat yourself, keep your views dumb, keep your controllers skinny, and keep business logic in your models. These principles carry most applications to their first release or beyond.
However, these principles only get you so far. After a few releases, most applications begin to suffer. Models become fat, classes become few and large, tests become slow and changes become painful. In many applications, there comes a day when the developers realize that there's no going back; the application is a twisted mess and the only way out is a rewrite or a new job.
Fortunately, it doesn't have to be this way. Developers have been using object-oriented programming for several decades and there's a wealth of knowledge out there that still applies to developing applications today. We can use the lessons learned by these developers to write good Rails applications by applying good object-oriented programming.
Ruby Science will outline a process for detecting emerging problems in code and will dive into the solutions, old and new.
Introduction
Code Smells
- Long Method
- Large Class
- Feature Envy
- Case Statement
- Shotgun Surgery
- Divergent Change
- Long Parameter List
- Duplicated Code
- Uncommunicative Name
- Single Table Inheritance
- Comments
- Mixins
- Callbacks
Solutions
- Replace Conditional with Polymorphism
- Replace Conditional with Null Object
- Extract Method
- Rename Method
- Extract Class
- Extract Value Object
- Extract Decorator
- Extract Partial
- Extract Validator
- Introduce Explaining Variable
- Introduce Form Object
- Introduce Parameter Object
- Use Class as Factory
- Move Method
- Inline Class
- Inject Dependencies
- Replace Subclasses with Strategies
- Replace Mixin with Composition
- Replace Callback with Method
- Use Convention Over Configuration