AlgoViz

SOLID in one page

medium 45 min

Five principles for classes that can be changed without fear: single responsibility, open/closed, Liskov substitution, interface segregation and dependency inversion.

Watch lesson5:16

Verify

Five checks with numbers, and the original program beside the new one.

The point: do not claim SOLID, show it. One check per letter, and each can fail.

Checks

One test per letter

LetterCheckResult here
SName the actor of each classOperations: text. Delivery team: senders. Monitoring: service
OAdd a kind and read the diffOne class, one line of wiring
LRun the contract test for each kindThree pass. The cutting SMS of the first version fails
ICount unused methods per implementer0
DWhich imports does the service need?Only data and ports

Trace of one bad evening

StepReturnsHistory
format[CRITICAL] db1: disk 95% full
email.sendReceipt(False, smtp down)email failed: smtp down
sms.sendReceipt(False, no number for ops)sms failed: no number for ops
chat.sendReceipt(True)chat ok
notify13 entries

The five wishes again

WishBeforeAfter
Host in the textAlertManagerAlertFormatter and the data
ChatAlertManagerChatSender, wiring
SMS loses textAlertManagerSmsSender, and a test for all
Read repliesA stub in every kindReplyReader for two kinds
Test without serverNot possibleA fake of three lines
Read everything at once12 linesAbout 60 lines in 8 classes
The last row is the bill. For two fixed channels and no tests it would be a bad deal.

Is it worth it here?