Episode 2 Part 1

Clean Code In The Browser, Episode 2 part 1

By Chris Powers

54 minMay 2017

In the first part of "Clean Code in the Browser" Episode 2, we start talking about the "S" in the SOLID Principles: the Single Responsibility Principle.

First, we discuss the meaning of software "best" practices. Everyone knows those are the practices that we're all supposed to be using, but is that always the truth?

We dive into the Single Responsibility Principle, identifying what it means, why it matters, and how we can apply it specifically to JavaScript. Picking up from some code we started in Episode 1, we use SRP as our guide for refactoring code structure and finding the right place for each piece of logic to live.

Finally, we explore how Command Query Separation can be a complimentary technique to SRP for reducing the scope and role of individual methods and functions. We work our way through another code example, finding opportunities to use both SRP and Command Query Separation to avoid code churn and cohesion.

This episode had so much content that we had to split it into two! Be sure to check out Episode 2 Part 2 for more insights into how SRP can help you write Clean Code in the Browser!