Implementation Patterns We Might Want to Avoid
Learn about the implementation patterns we might need to avoid for our Rails application.
There are three patterns we have seen frequently that we don’t think deliver the value developers often think they will. We are not saying we should never use these patterns, but that we need to be honest about the problem we are solving by applying them, how serious that problem is, and how well the patterns actually do solve it. The patterns are:
- Creating class methods instead of instance methods.
- Using a generalized method name like
call
. - Using dependency injection.
Let’s discuss them one by one to have a better idea of what we are talking about.
Creating class methods closes doors
Developers often bristle at having to call .new
or putting a method in a class that has no state. They think it’s more clean/compact/expedient/correct to declare this lack of state by making a class method:
Get hands-on with 1400+ tech skills courses.