One of These Things Is Not Like The Others
There's a programming principle we saw earlier in the book called the Single Responsibility Principle.
When looking at classes or methods that are doing too much, using the SRP as a guiding light can help us to make code that is easier to maintain, less coupled, and therefore leads to fewer bugs.
Let's look at a generic User
class that might be similar to code that you've seen before:
class User { public firstName: string; public lastName: string; public id: number; public jwtToken: string; public homeAddress: string; public creditCardNo: string; public getFullName(): string { return this.firstName + " " + this.lastName; } public decodeJwtToken(): string { return decode(this.jwtToken); } }
Look familiar?
Given the name of the class, we should start to be suspicious that it's too generic a class...
You Have Mail
You've been tasked...