For homework, I read last night the chapter on the Single Responsibility Principle (SRP) from Sandi Metz’s book “Practical Object-Oriented Design in Ruby“.
SRP is the idea that a class should have only one responsibility because they are easy to change and therefore easy to reuse.
If you are a visual person, the picture below will give you an idea:
Think of each individual piece of the swiss knife as a method and each method has a sole behavior. The SRP is about structuring your methods in a way that can be easily changed if you need to. As I am learning about Ruby classes, I can see right away the benefit of this principle. A burdensome piece of code that makes modification difficulty is prone to bugs. If each code defines one object behavior, you also avoid the need for commenting on your methods.
I am eager to learn more about this principle and ways I can implement it. I want to write classes that are classy and singly responsible.