The SOLID principles are a collection of five object-oriented principles of class design. The principles themselves, which were put into the SOLID acronym by Robert Martin, are acronyms within the acronym: SRP, OCP, LSP, ISP, and DIP. We will be leveraging each of these principles in our class design moving forward.
Single Responsibility Principle (SRP) can loosely be translated as "do one thing and do it well." If you find yourself describing the functionality of a class or method by saying it does A "and" B, you've likely violated this principle. Consider our controllers.
One could argue that our app's RecipeController
class violates SRP, as it currently retrieves data on behalf of the user, translates the data to a format appropriate for the view, and either returns the user the requested view or reroutes them to the appropriate one. That's a lot of work going on. However, if we state that the intent of our application's RecipeController...