Exercises
Each one is a small Java project that already works. Restructure the single file you are allowed to edit, then submit — and a requirement you have never seen is dropped in without letting you touch your code again. Follow the principle and nothing you wrote needs to change.
| Status | # | Title | Difficulty | Family | Hidden |
|---|---|---|---|---|---|
| Not started | 1 | Open/ClosedAdd a shape without editing the thing that measures shapes. | Easy | SOLID | 1 hidden requirement |
| Not started | 2 | Single ResponsibilityOne class, two jobs, and two people who will want to change it. | Easy | SOLID | 2 hidden requirements |
| Not started | 3 | Liskov SubstitutionA caller that assumed too much, and the subtype that found out. | Medium | SOLID | 1 hidden requirement |
| Not started | 4 | Interface SegregationIt only prints. So why does it insist on a fax machine? | Medium | SOLID | 1 hidden requirement |
| Not started | 5 | Dependency InversionThe report picks its own database, so nobody else can. | Medium | SOLID | 1 hidden requirement |
| Not started | 6 | Factory MethodThe dialog knows what to do with a button. It should not know which one. | Easy | Creational | 1 hidden requirement |
| Not started | 7 | Abstract FactoryA dark button beside a light checkbox. Nobody chose that; it just happened. | Hard | Creational | 1 hidden requirement |
| Not started | 8 | BuilderThe same order, written twice: once for the customer, once for the kitchen. | Medium | Creational | 1 hidden requirement |
| Not started | 9 | PrototypeA copy that was right on the day it was written. | Medium | Creational | 1 hidden requirement |
| Not started | 10 | AdapterThere is a converter right there. The panel went round it. | Easy | Structural | 1 hidden requirement |
| Not started | 11 | BridgeTwo shapes, one renderer. Add a third of either and see what happens. | Hard | Structural | 2 hidden requirements |
| Not started | 12 | CompositeIt handles a folder in a folder. Nobody asked what happens at three. | Medium | Structural | 1 hidden requirement |
| Not started | 13 | DecoratorOne flag per channel. Now stack two of them. | Medium | Structural | 1 hidden requirement |
| Not started | 14 | FacadeThere is a front door. Everyone climbs in through the window. | Easy | Structural | 1 hidden requirement |
| Not started | 15 | FlyweightFour thousand letters. Sixteen of them are different. | Hard | Structural | 1 hidden requirement |
| Not started | 16 | ProxyThe report is lazy. The dashboard woke it up anyway. | Medium | Structural | 1 hidden requirement |
| Not started | 17 | Chain of ResponsibilityTwo checks, hard-coded in the order somebody happened to write them. | Medium | Behavioural | 1 hidden requirement |
| Not started | 18 | CommandUndo works. Press it twice. | Medium | Behavioural | 1 hidden requirement |
| Not started | 19 | IteratorCounting to the size and indexing in. Fine, until there is no index. | Medium | Behavioural | 1 hidden requirement |
| Not started | 20 | MediatorTwo people in a room, wired to each other by hand. Now let a third in. | Medium | Behavioural | 1 hidden requirement |
| Not started | 21 | ObserverA field for the logger, a field for the alarm. Room for exactly two opinions. | Easy | Behavioural | 1 hidden requirement |
| Not started | 22 | StateDraft, review, published. Squeeze one in the middle. | Medium | Behavioural | 1 hidden requirement |
| Not started | 23 | StrategyIt was given the calculation. It does the arithmetic itself anyway. | Easy | Behavioural | 1 hidden requirement |
| Not started | 24 | Template MethodRead, transform, write. The order is the same every time; the steps are not. | Easy | Behavioural | 1 hidden requirement |
| Not started | 25 | VisitorOne walker per operation, and each one knows every node type. | Hard | Behavioural | 1 hidden requirement |
| Read onlyThree patterns cannot be graded by dropping a requirement on them, and each of these says why. Nothing to write — the code is here to read and run. | |||||
| Nothing to solve | 26 | SingletonIt works. That is the problem with it. | Read | Creational | — |
| Nothing to solve | 27 | MementoUndo, without the thing that stores it ever seeing what it stores. | Read | Behavioural | — |
| Nothing to solve | 28 | InterpreterOne class per rule, and a tree that is its own evaluator. | Read | Behavioural | — |
Nothing matches that. Try a shorter word.
TERMINALPROBLEMSOUTPUT
Try:
honeytrap shell. Two commands are wired up: cd and cat.