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

UML design

The final classes, and the letters written on the arrows.

The point: every letter can be seen in the picture. S is the number of boxes, I is the size of the interfaces, D is the direction of the arrows, O is the free place beside the last box, L is what the dashed arrows promise.

Design

Alert service

All five letters in one picture

AlertService+ notify(alert, to)AlertFormatter+ format(alert): str

1/5S

The service keeps the order. The formatter owns the text.

usesimplements

Draw this in an interview and say one sentence per letter. It takes a minute.

Not drawn, on purpose

CandidateWhy not
Interface for AlertFormatterOne implementation, no outside world
AbstractSender base classNothing to share yet. Retry becomes a decorator, see the FAANG interview pages
SenderFactoryOne composition root is enough
ReplyReader in this serviceIt never reads replies
Class per severityOnly a word differs: data

One alert at run time

The second sender could not deliver. It kept its promise anyway: it said so in a receipt.