{"id":"6b08bd3f80884893657cca49","slug":"gof-behavioral","title":"GoF behavioral patterns","description":"Ten behavioral patterns from the Gang of Four catalog, told through Halina's pierogi place moving online: from Strategy and Observer to Memento and Visitor. Every article has a diagram, code in C#, TypeScript, Java, Go and Python, a quiz and advice on when not to use the pattern.","level":"intermediate","cover":null,"order":3,"itemCount":10,"articleCount":10,"topicCount":0,"minutes":129,"groups":["behavioral"],"covers":[],"preview":[{"kind":"article","title":"Strategy: interchangeable algorithms instead of an if-else ladder","slug":"strategy","topicSlug":null},{"kind":"article","title":"Observer: notify everyone without knowing anyone","slug":"observer","topicSlug":null},{"kind":"article","title":"Command: a request wrapped in an object","slug":"command","topicSlug":null},{"kind":"article","title":"State: an object that changes behaviour with its life stage","slug":"state","topicSlug":null}],"articleIds":["6b08bd3e80884893657cca1a","6b08bd3c80884893657cc9dd","6b08bd3080884893657cc910","6b08bd3d80884893657cca0f","6b08bd3e80884893657cca24","6b08bd3980884893657cc996","6b08bd3080884893657cc8fc","6b08bd3a80884893657cc9aa","6b08bd3a80884893657cc9b4","6b08bd3f80884893657cca38"],"items":[{"kind":"article","articleId":"6b08bd3e80884893657cca1a","slug":"strategy","topicSlug":null,"title":"Strategy: interchangeable algorithms instead of an if-else ladder","summary":"The Strategy pattern through courier assignment in a pierogi place: a family of interchangeable algorithms behind one interface, swapped at runtime. Code in C#, TypeScript, Java, Go and Python.","readingMinutes":13,"note":"","cover":null,"group":"behavioral","icon":"route","techs":["dotnet","typescript","java","go","python"],"level":"beginner","status":"available"},{"kind":"article","articleId":"6b08bd3c80884893657cc9dd","slug":"observer","topicSlug":null,"title":"Observer: notify everyone without knowing anyone","summary":"The Observer pattern through a pierogi place's pantry: when the cheese runs out, the menu, the shopping list and alerts react on their own, and the pantry does not know they exist. Subscribing, unsubscribing, pitfalls and code in five languages.","readingMinutes":13,"note":"","cover":null,"group":"behavioral","icon":"eye","techs":["dotnet","typescript","java","go","python"],"level":"beginner","status":"available"},{"kind":"article","articleId":"6b08bd3080884893657cc910","slug":"command","topicSlug":null,"title":"Command: a request wrapped in an object","summary":"The Command pattern through a waiter's terminal in a pierogi place: every action on the ticket is an object with execute and undo, so it can be undone, redone, kept in a history and sent to a queue. Code in five languages.","readingMinutes":12,"note":"","cover":null,"group":"behavioral","icon":"terminal","techs":["dotnet","typescript","java","go","python"],"level":"intermediate","status":"available"},{"kind":"article","articleId":"6b08bd3d80884893657cca0f","slug":"state","topicSlug":null,"title":"State: an object that changes behaviour with its life stage","summary":"The State pattern through an order in a pierogi place: New, Paid, InKitchen, Delivered and Cancelled as separate objects that guard the allowed transitions themselves. A state machine without an if-else ladder, code in five languages.","readingMinutes":13,"note":"","cover":null,"group":"behavioral","icon":"toggle-right","techs":["dotnet","typescript","java","go","python"],"level":"intermediate","status":"available"},{"kind":"article","articleId":"6b08bd3e80884893657cca24","slug":"template-method","topicSlug":null,"title":"Template Method: a fixed recipe, interchangeable ingredients","summary":"The Template Method pattern through importing supplier price lists: the base class fixes the order of steps, and subclasses provide parsing and optional hooks. The Hollywood principle, an inheritance-free variant in Go and code in five languages.","readingMinutes":13,"note":"","cover":null,"group":"behavioral","icon":"layout-template","techs":["dotnet","typescript","java","go","python"],"level":"beginner","status":"available"},{"kind":"article","articleId":"6b08bd3980884893657cc996","slug":"iterator","topicSlug":null,"title":"Iterator: walking a collection without looking inside","summary":"The Iterator pattern through orders from a delivery app fetched page by page: the loop in the report knows nothing about pagination, and pages load lazily, only when needed. Generators, yield and iter.Seq in five languages.","readingMinutes":11,"note":"","cover":null,"group":"behavioral","icon":"list-ordered","techs":["dotnet","typescript","java","go","python"],"level":"beginner","status":"available"},{"kind":"article","articleId":"6b08bd3080884893657cc8fc","slug":"chain-of-responsibility","topicSlug":null,"title":"Chain of Responsibility: pass it on until someone takes care of it","summary":"The Chain of Responsibility pattern through complaints in a pierogi place: a bot, a shift manager and the owner form a chain, and a complaint travels until it reaches someone authorised. The classic variant and the middleware pipeline, code in five languages.","readingMinutes":13,"note":"","cover":null,"group":"behavioral","icon":"link","techs":["dotnet","typescript","java","go","python"],"level":"intermediate","status":"available"},{"kind":"article","articleId":"6b08bd3a80884893657cc9aa","slug":"mediator","topicSlug":null,"title":"Mediator: components talk through a coordinator","summary":"The Mediator pattern through the order form of a pierogi place: the delivery choice, address, time slot and button do not know each other, and the rules of their cooperation live in one place. Plus an honest look at MediatR and code in five languages.","readingMinutes":12,"note":"","cover":null,"group":"behavioral","icon":"messages-square","techs":["dotnet","typescript","java","go","python"],"level":"intermediate","status":"available"},{"kind":"article","articleId":"6b08bd3a80884893657cc9b4","slug":"memento","topicSlug":null,"title":"Memento: a state snapshot without breaking encapsulation","summary":"The Memento pattern through a menu editor: Halina saves versions of the menu and returns to them with one click, while the history keeps snapshots without seeing what is inside. Copies instead of references, memory costs and code in five languages.","readingMinutes":13,"note":"","cover":null,"group":"behavioral","icon":"save","techs":["dotnet","typescript","java","go","python"],"level":"intermediate","status":"available"},{"kind":"article","articleId":"6b08bd3f80884893657cca38","slug":"visitor","topicSlug":null,"title":"Visitor: new operations without changing classes","summary":"The Visitor pattern through a menu: dishes, drinks and sets stay untouched, while pricing, an allergen report or an export are separate visitor objects. Double dispatch, a comparison with pattern matching and code in five languages.","readingMinutes":16,"note":"","cover":null,"group":"behavioral","icon":"footprints","techs":["dotnet","typescript","java","go","python"],"level":"advanced","status":"available"}],"others":[{"id":"6b08bd4080884893657cca50","slug":"gof-creational","title":"GoF creational patterns","description":"Five ways to stop object creation from being scattered all over your code: from Factory Method through Abstract Factory, Builder and Prototype to Singleton – with examples in C#, TypeScript, Java, Go and Python.","level":"intermediate","cover":null,"order":1,"itemCount":5},{"id":"6b08bd4080884893657cca57","slug":"gof-structural","title":"GoF structural patterns","description":"Seven patterns about composing classes and objects into larger structures: Adapter, Bridge, Composite, Decorator, Facade, Flyweight and Proxy. Each with a real-life problem, a diagram and code in five languages.","level":"intermediate","cover":null,"order":2,"itemCount":7},{"id":"6b08bd3f80884893657cca42","slug":"architecture-path","title":"From monolith to microservices","description":"A path through architecture styles in the order you usually meet them in a growing system: from the monolith and modules, through layers, the hexagon, clean and onion architecture and vertical slices, to CQRS, event sourcing, events, microservices and strategic DDD.","level":"intermediate","cover":null,"order":4,"itemCount":12}]}