The Rabbit Hole
253. SOLID - Single Responsibility Principle (Replay)
Do you know how you can feel overwhelmed when you have too much on your plate? Well, your code can feel the same way. This is why it’s important to follow the Single Responsibility Principle, SRP, which is what the ‘s’ in SOLID stands for. Today we do a deep dive into the SRP and how you can ensure that your class or object only does one thing at a time. We take a look at some of the benefits of following the SRP, such as ease of testing and greater flexibility with making changes. When there is more than one responsibility designated to a class, it can quickly become confusing when you need to alter a piece of code. We also look into why you should try to keep classes as small as you can, how to know if a class or object has more than one responsibility, and why you should always be ready to refactor.