Bridge pattern 00:00:00 Make a prediction You will identify two independent dimensions and check that either can grow without giving every combination a new class. Two remotes work with a radio and a television. Is adding a third device supposed to require one device-specific subclass for every remote? No. Let each remote use the same device contract and implement the new device once. The ability to add either a remote or a device independently is the point of the bridge. 00:00:31 Puppets and sticks A puppet has a ring and a control stick has a hook. A fox fits the short or long stick, and a new owl fits both. A magnetic stick with no hook still fails, despite being a new kind of stick. The puppet and control implementation vary independently because they agree at the joint. The joint's behavioural promise is what keeps the cross-product manageable. The Bridge pattern is a structural design pattern. It takes a class that varies in two ways and splits it into two hierarchies: the abstraction, which clients use, and the implementor, which does the platform's part. Inheritance can express one question. With two questions it needs a class for each pair of answers, and code is copied between the branches. 00:01:19 Change the remote and the device independently A simple remote and an advanced remote should each work with a television and a radio. Inheriting one class per combination multiplies the designs. Let each remote hold a device interface. Pressing power asks whichever device is attached to change state. Add a radio and exercise it with both existing remotes. Then add a programmable remote and reuse both devices. Two separately growing dimensions are the clue. Attach the basic remote to a speaker, raise the volume, and then attach the same remote type to a television. Only the device implementation changes. Add a programmable remote afterward. With separate axes it can reuse both devices instead of creating four separate remote-device combinations. 00:02:06 Compare two reporting dimensions Reports vary by content, while rendering varies between HTML and plain text. Pass a renderer into each report abstraction so content and output representation can evolve separately. If only the sorting algorithm varies inside one report, a simple strategy is sufficient. Render a weekly sales report as plain text, then as HTML. Its totals should match. Next add stock counts as a new report content type. If every renderer needs a special case for stock counts, inspect whether the content and rendering contracts genuinely separate the two changes. A new device unable to perform the contract's basic power operation cannot join merely by having the right method name. A strategy inside one algorithm is a smaller choice when only one algorithm changes and there are not two independently evolving families. Go: log/slog. A Logger offers Info, Error and With to callers, and passes records to a Handler that formats and writes them. Anyone can write a Handler, and the Logger does not change. Qt Platform Abstraction. Qt's main platform layer. Classes with the prefix QPlatform are used to implement higher level classes, and a plugin provides them for one window system. 00:03:27 Try an interview follow-up When would you remove a bridge? When after a long time one side has one variant and no second is planned, or when every change goes through both sides. Then the interface in the middle is only a toll. I would inline the one implementation and keep its tests. A remote can be basic or programmable, and the device can be a television or a speaker. Add a speaker without writing a separate remote class for each combination. Have the remote call a device contract. Then add a programmable remote and trace why the speaker implementation stays useful. 00:04:05 What to take with you Two questions, two hierarchies, one reference. Arrows cross the middle in one direction only. The implementor has small steps named after the platform. Abstractions build features from them and keep the state of features.