{"id":"6b08bd3a80884893657cc9aa","slug":"mediator","title":"Mediator: komponenty rozmawiają przez koordynatora","summary":"Wzorzec Mediator na przykładzie formularza zamówienia w pierogarni: wybór dostawy, adres, godzina i przycisk nie znają się nawzajem, a reguły ich współpracy żyją w jednym miejscu. Do tego uczciwie o MediatR i kod w pięciu językach.","servedLang":"pl","availableLangs":["pl","en"],"topics":["mediator","cqrs"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","behavioral","mediator","ui","mediatr","coupling"],"level":"intermediate","kind":"article","access":"members","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":11,"stats":{"views":2,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:14:02.221Z","updatedAt":"2026-11-27T10:05:00.090Z","requestedLang":"pl","theme":{"hero":"classic","heroMedia":null,"accent":"violet","background":"grid","weaveResources":true,"toc":"right"},"seoDescription":"Wzorzec projektowy Mediator w C#, TypeScript, Java, Go i Python: koordynacja komponentów formularza, sieć zależności kontra gwiazda, MediatR i kiedy go nie potrzebujesz.","wordCount":2168,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Formularz zamówienia na stronie pierogarni Haliny ma cztery elementy: przełącznik „odbiór/dostawa”, pole adresu, wybór godziny i przycisk „Zamawiam”. Brzmi prosto, dopóki nie okaże się, że każdy wpływa na każdy: dostawa pokazuje adres i zmienia godziny, a przycisk zależy od wszystkich trzech. "},{"type":"text","text":"Mediator","marks":[{"type":"bold"}]},{"type":"text","text":" zabiera tę wiedzę komponentom i trzyma ją w jednym obiekcie."}]},{"type":"callout","attrs":{"variant":"tip","title":"W skrócie"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Komponenty ("},{"type":"text","text":"colleagues","marks":[{"type":"italic"}]},{"type":"text","text":") "},{"type":"text","text":"nie odwołują się do siebie nawzajem","marks":[{"type":"bold"}]},{"type":"text","text":" – zgłaszają zmiany mediatorowi."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Mediator zna wszystkich uczestników i "},{"type":"text","text":"centralizuje reguły ich współpracy","marks":[{"type":"bold"}]},{"type":"text","text":"."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Sieć zależności „każdy z każdym” zamienia się w gwiazdę: każdy zna tylko środek."}]}]}]}]},{"type":"stats","attrs":{"items":[{"value":"4","label":"komponenty formularza","hint":"przełącznik, adres, godzina, przycisk"},{"value":"12 → 4","label":"możliwe zależności","hint":"sieć każdy z każdym kontra gwiazda"},{"value":"1","label":"miejsce na reguły","hint":"metoda notify mediatora"}]}},{"type":"heading","attrs":{"level":2,"id":"problem-siec-zaleznosci"},"content":[{"type":"text","text":"Problem: sieć zależności"}]},{"type":"paragraph","content":[{"type":"text","text":"Pierwsza wersja formularza podpinała reakcje bezpośrednio pod komponenty:"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"order-form-before.ts"},"content":[{"type":"text","text":"deliveryToggle.onChange = (mode) => {\n  addressField.visible = mode === 'delivery';\n  slotPicker.load(mode === 'delivery' ? deliverySlots : pickupSlots);\n  submitButton.enabled = !!slotPicker.selected && (mode === 'pickup' || addressField.value !== '');\n};\naddressField.onChange = (value) => {\n  submitButton.enabled = !!slotPicker.selected && (deliveryToggle.mode === 'pickup' || value !== '');\n};\nslotPicker.onChange = (slot) => {\n  submitButton.enabled = !!slot && (deliveryToggle.mode === 'pickup' || addressField.value !== ''); // third copy\n};"}]},{"type":"paragraph","content":[{"type":"text","text":"Warunek aktywności przycisku istnieje w trzech kopiach i już się różni ("},{"type":"text","text":"!!slotPicker.selected","marks":[{"type":"code"}]},{"type":"text","text":" kontra "},{"type":"text","text":"!!slot","marks":[{"type":"code"}]},{"type":"text","text":"). Przełącznik musi znać adres, listę godzin i przycisk; pole adresu musi znać przełącznik i przycisk. Komponentów nie da się użyć ponownie w innym formularzu, bo każdy ciągnie za sobą pozostałe. Przy czterech elementach możliwych powiązań jest dwanaście – przy ośmiu byłoby ich pięćdziesiąt sześć."}]},{"type":"columns","attrs":{"layout":"1-1","valign":"top"},"content":[{"type":"column","content":[{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart TB\n  T[\"Przełącznik\"] <--> A[\"Adres\"]\n  T <--> S[\"Godzina\"]\n  T <--> B[\"Przycisk\"]\n  A <--> S\n  A <--> B\n  S <--> B","caption":"Bez mediatora: każdy zna każdego"}}]},{"type":"column","content":[{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart LR\n  T[\"Przełącznik\"] <--> M{{\"OrderForm (mediator)\"}}\n  A[\"Adres\"] <--> M\n  M <--> S[\"Godzina\"]\n  M <--> B[\"Przycisk\"]","caption":"Z mediatorem: gwiazda"}}]}]},{"type":"heading","attrs":{"level":2,"id":"rozwiazanie-jeden-koordynator"},"content":[{"type":"text","text":"Rozwiązanie: jeden koordynator"}]},{"type":"paragraph","content":[{"type":"text","text":"Każdy komponent dostaje referencję do mediatora i przy każdej zmianie woła "},{"type":"text","text":"mediator.notify(this)","marks":[{"type":"code"}]},{"type":"text","text":". Nie wie, kto i jak zareaguje. Mediator – tu sam formularz "},{"type":"text","text":"OrderForm","marks":[{"type":"code"}]},{"type":"text","text":" – zna wszystkie komponenty i w jednej metodzie decyduje, co z czego wynika: wybór dostawy pokazuje adres i ładuje godziny dostaw, a każda zmiana przelicza stan przycisku."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"sequenceDiagram\n  actor U as Klient\n  participant T as DeliveryMode\n  participant M as OrderForm (mediator)\n  participant A as AddressField\n  participant S as SlotPicker\n  participant B as SubmitButton\n  U->>T: choose(\"pickup\")\n  T->>M: notify(this)\n  M->>A: visible = false\n  M->>S: options = godziny odbioru, selected = null\n  M->>B: enabled = false","caption":"Klient przełącza się z dostawy na odbiór"}},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Rola"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"W przykładzie"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Odpowiedzialność"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Mediator"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"FormMediator","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"interfejs, przez który komponenty zgłaszają zmiany"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Konkretny mediator"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"OrderForm","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zna komponenty, zawiera reguły ich współpracy"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Współpracownik ("},{"type":"text","text":"Colleague","marks":[{"type":"italic"}]},{"type":"text","text":")"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Component","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zna tylko mediatora"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Konkretni współpracownicy"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"DeliveryMode","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"AddressField","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"SlotPicker","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"SubmitButton","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"własny stan i zachowanie, bez wiedzy o innych"}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"implementacja-w-pieciu-jezykach"},"content":[{"type":"text","text":"Implementacja w pięciu językach"}]},{"type":"paragraph","content":[{"type":"text","text":"Komponenty są celowo „głupie”: przechowują swój stan i zgłaszają zmianę. Cała logika zależności siedzi w metodzie "},{"type":"text","text":"notify","marks":[{"type":"code"}]},{"type":"text","text":" mediatora. W Go przycisk jest po prostu polem "},{"type":"text","text":"SubmitEnabled","marks":[{"type":"code"}]},{"type":"text","text":", a mediator rozpoznaje nadawcę po wskaźniku."}]},{"type":"codeGroup","attrs":{"title":"Mediator – formularz zamówienia"},"content":[{"type":"codeBlock","attrs":{"language":"csharp","filename":"OrderForm.cs"},"content":[{"type":"text","text":"var form = new OrderForm();\nform.Mode.Choose(\"delivery\");           // address shown, delivery slots loaded\nform.Address.Type(\"Długa 5\");\nform.Slots.Pick(\"18:30\");\nConsole.WriteLine(form.Submit.Enabled); // True\nform.Mode.Choose(\"pickup\");             // address hidden, slot reset\nConsole.WriteLine(form.Submit.Enabled); // False\n\npublic interface IFormMediator\n{\n    void Notify(Component sender);\n}\n\n// Components only know the mediator, never each other.\npublic abstract class Component(IFormMediator mediator)\n{\n    protected void Changed() => mediator.Notify(this);\n}\n\npublic sealed class DeliveryMode(IFormMediator m) : Component(m)\n{\n    public string Value { get; private set; } = \"pickup\";\n    public void Choose(string value) { Value = value; Changed(); }\n}\n\npublic sealed class AddressField(IFormMediator m) : Component(m)\n{\n    public bool Visible { get; set; }\n    public string Text { get; private set; } = \"\";\n    public void Type(string text) { Text = text; Changed(); }\n}\n\npublic sealed class SlotPicker(IFormMediator m) : Component(m)\n{\n    public string[] Options { get; set; } = [];\n    public string? Selected { get; set; }\n    public void Pick(string slot) { Selected = Options.Contains(slot) ? slot : null; Changed(); }\n}\n\npublic sealed class SubmitButton(IFormMediator m) : Component(m)\n{\n    public bool Enabled { get; set; }\n}\n\n// The mediator is the only place that knows how components affect each other.\npublic sealed class OrderForm : IFormMediator\n{\n    public DeliveryMode Mode { get; }\n    public AddressField Address { get; }\n    public SlotPicker Slots { get; }\n    public SubmitButton Submit { get; }\n\n    public OrderForm()\n    {\n        (Mode, Address, Slots, Submit) = (new(this), new(this), new(this), new(this));\n        Notify(Mode);\n    }\n\n    public void Notify(Component sender)\n    {\n        if (sender == Mode)\n        {\n            Address.Visible = Mode.Value == \"delivery\";\n            Slots.Options = Address.Visible ? [\"18:30\", \"19:00\"] : [\"17:45\", \"18:00\", \"18:15\"];\n            Slots.Selected = null;\n        }\n        Submit.Enabled = Slots.Selected is not null && (!Address.Visible || Address.Text.Length > 0);\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"order-form.ts"},"content":[{"type":"text","text":"interface FormMediator {\n  notify(sender: Component): void;\n}\n\n// Components only know the mediator, never each other.\nabstract class Component {\n  constructor(protected readonly mediator: FormMediator) {}\n  protected changed(): void { this.mediator.notify(this); }\n}\n\nclass DeliveryMode extends Component {\n  value: 'pickup' | 'delivery' = 'pickup';\n  choose(value: 'pickup' | 'delivery'): void { this.value = value; this.changed(); }\n}\n\nclass AddressField extends Component {\n  visible = false;\n  text = '';\n  type(text: string): void { this.text = text; this.changed(); }\n}\n\nclass SlotPicker extends Component {\n  options: string[] = [];\n  selected: string | null = null;\n  pick(slot: string): void { this.selected = this.options.includes(slot) ? slot : null; this.changed(); }\n}\n\nclass SubmitButton extends Component {\n  enabled = false;\n}\n\n// The mediator is the only place that knows how components affect each other.\nclass OrderForm implements FormMediator {\n  readonly mode = new DeliveryMode(this);\n  readonly address = new AddressField(this);\n  readonly slots = new SlotPicker(this);\n  readonly submit = new SubmitButton(this);\n\n  constructor() { this.notify(this.mode); }\n\n  notify(sender: Component): void {\n    if (sender === this.mode) {\n      this.address.visible = this.mode.value === 'delivery';\n      this.slots.options = this.address.visible ? ['18:30', '19:00'] : ['17:45', '18:00', '18:15'];\n      this.slots.selected = null;\n    }\n    this.submit.enabled = this.slots.selected !== null && (!this.address.visible || this.address.text !== '');\n  }\n}\n\nconst form = new OrderForm();\nform.mode.choose('delivery');\nform.address.type('Długa 5');\nform.slots.pick('18:30');\nconsole.log(form.submit.enabled); // true\nform.mode.choose('pickup');\nconsole.log(form.submit.enabled); // false – pick a pickup slot first"}]},{"type":"codeBlock","attrs":{"language":"java","filename":"OrderForm.java"},"content":[{"type":"text","text":"import java.util.List;\n\ninterface FormMediator {\n    void notify(Component sender);\n}\n\n// Components only know the mediator, never each other.\nabstract class Component {\n    private final FormMediator mediator;\n    Component(FormMediator mediator) { this.mediator = mediator; }\n    protected void changed() { mediator.notify(this); }\n}\n\nclass DeliveryMode extends Component {\n    String value = \"pickup\";\n    DeliveryMode(FormMediator m) { super(m); }\n    void choose(String value) { this.value = value; changed(); }\n}\n\nclass AddressField extends Component {\n    boolean visible;\n    String text = \"\";\n    AddressField(FormMediator m) { super(m); }\n    void type(String text) { this.text = text; changed(); }\n}\n\nclass SlotPicker extends Component {\n    List<String> options = List.of();\n    String selected;\n    SlotPicker(FormMediator m) { super(m); }\n    void pick(String slot) { selected = options.contains(slot) ? slot : null; changed(); }\n}\n\nclass SubmitButton extends Component {\n    boolean enabled;\n    SubmitButton(FormMediator m) { super(m); }\n}\n\n// The mediator is the only place that knows how components affect each other.\npublic class OrderForm implements FormMediator {\n    final DeliveryMode mode = new DeliveryMode(this);\n    final AddressField address = new AddressField(this);\n    final SlotPicker slots = new SlotPicker(this);\n    final SubmitButton submit = new SubmitButton(this);\n\n    OrderForm() { notify(mode); }\n\n    @Override public void notify(Component sender) {\n        if (sender == mode) {\n            address.visible = mode.value.equals(\"delivery\");\n            slots.options = address.visible ? List.of(\"18:30\", \"19:00\") : List.of(\"17:45\", \"18:00\", \"18:15\");\n            slots.selected = null;\n        }\n        submit.enabled = slots.selected != null && (!address.visible || !address.text.isEmpty());\n    }\n\n    public static void main(String[] args) {\n        var form = new OrderForm();\n        form.mode.choose(\"delivery\");\n        form.address.type(\"Długa 5\");\n        form.slots.pick(\"18:30\");\n        System.out.println(form.submit.enabled); // true\n        form.mode.choose(\"pickup\");\n        System.out.println(form.submit.enabled); // false\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"go","filename":"order_form.go"},"content":[{"type":"text","text":"package main\n\nimport (\n\t\"fmt\"\n\t\"slices\"\n)\n\n// Mediator is the only thing components know about.\ntype Mediator interface{ Changed(sender any) }\n\ntype DeliveryMode struct {\n\tm     Mediator\n\tValue string\n}\n\nfunc (d *DeliveryMode) Choose(v string) {\n\td.Value = v\n\td.m.Changed(d)\n}\n\ntype AddressField struct {\n\tm       Mediator\n\tVisible bool\n\tText    string\n}\n\nfunc (a *AddressField) Type(t string) {\n\ta.Text = t\n\ta.m.Changed(a)\n}\n\ntype SlotPicker struct {\n\tm        Mediator\n\tOptions  []string\n\tSelected string\n}\n\nfunc (s *SlotPicker) Pick(slot string) {\n\ts.Selected = \"\"\n\tif slices.Contains(s.Options, slot) {\n\t\ts.Selected = slot\n\t}\n\ts.m.Changed(s)\n}\n\n// OrderForm coordinates the components; the submit button is just a flag here.\ntype OrderForm struct {\n\tMode          DeliveryMode\n\tAddress       AddressField\n\tSlots         SlotPicker\n\tSubmitEnabled bool\n}\n\nfunc NewOrderForm() *OrderForm {\n\tf := &OrderForm{}\n\tf.Mode, f.Address, f.Slots = DeliveryMode{m: f, Value: \"pickup\"}, AddressField{m: f}, SlotPicker{m: f}\n\tf.Changed(&f.Mode)\n\treturn f\n}\n\nfunc (f *OrderForm) Changed(sender any) {\n\tif sender == &f.Mode {\n\t\tf.Address.Visible = f.Mode.Value == \"delivery\"\n\t\tf.Slots.Options = []string{\"17:45\", \"18:00\", \"18:15\"}\n\t\tif f.Address.Visible {\n\t\t\tf.Slots.Options = []string{\"18:30\", \"19:00\"}\n\t\t}\n\t\tf.Slots.Selected = \"\"\n\t}\n\tf.SubmitEnabled = f.Slots.Selected != \"\" && (!f.Address.Visible || f.Address.Text != \"\")\n}\n\nfunc main() {\n\tf := NewOrderForm()\n\tf.Mode.Choose(\"delivery\")\n\tf.Address.Type(\"Długa 5\")\n\tf.Slots.Pick(\"18:30\")\n\tfmt.Println(f.SubmitEnabled) // true\n\tf.Mode.Choose(\"pickup\")\n\tfmt.Println(f.SubmitEnabled) // false\n}"}]},{"type":"codeBlock","attrs":{"language":"python","filename":"order_form.py"},"content":[{"type":"text","text":"from __future__ import annotations\n\n\nclass Component:\n    \"\"\"Components only know the mediator, never each other.\"\"\"\n\n    def __init__(self, mediator: OrderForm) -> None:\n        self._mediator = mediator\n\n    def _changed(self) -> None:\n        self._mediator.notify(self)\n\n\nclass DeliveryMode(Component):\n    value = \"pickup\"\n\n    def choose(self, value: str) -> None:\n        self.value = value\n        self._changed()\n\n\nclass AddressField(Component):\n    visible = False\n    text = \"\"\n\n    def type(self, text: str) -> None:\n        self.text = text\n        self._changed()\n\n\nclass SlotPicker(Component):\n    options: list[str] = []\n    selected: str | None = None\n\n    def pick(self, slot: str) -> None:\n        self.selected = slot if slot in self.options else None\n        self._changed()\n\n\nclass OrderForm:\n    \"\"\"The mediator: the only place that knows how components affect each other.\"\"\"\n\n    def __init__(self) -> None:\n        self.mode = DeliveryMode(self)\n        self.address = AddressField(self)\n        self.slots = SlotPicker(self)\n        self.submit_enabled = False\n        self.notify(self.mode)\n\n    def notify(self, sender: Component) -> None:\n        if sender is self.mode:\n            self.address.visible = self.mode.value == \"delivery\"\n            self.slots.options = [\"18:30\", \"19:00\"] if self.address.visible else [\"17:45\", \"18:00\", \"18:15\"]\n            self.slots.selected = None\n        self.submit_enabled = self.slots.selected is not None and (\n            not self.address.visible or self.address.text != \"\"\n        )\n\n\nform = OrderForm()\nform.mode.choose(\"delivery\")\nform.address.type(\"Długa 5\")\nform.slots.pick(\"18:30\")\nprint(form.submit_enabled)  # True\nform.mode.choose(\"pickup\")\nprint(form.submit_enabled)  # False"}]}]}]},"toc":[{"id":"problem-siec-zaleznosci","text":"Problem: sieć zależności","level":2,"locked":false},{"id":"rozwiazanie-jeden-koordynator","text":"Rozwiązanie: jeden koordynator","level":2,"locked":false},{"id":"implementacja-w-pieciu-jezykach","text":"Implementacja w pięciu językach","level":2,"locked":false},{"id":"krok-po-kroku","text":"Krok po kroku","level":2,"locked":true},{"id":"mediator-a-mediatr","text":"Mediator a MediatR","level":2,"locked":true},{"id":"kiedy-stosowac-a-kiedy-nie","text":"Kiedy stosować, a kiedy nie","level":2,"locked":true},{"id":"powiazania-z-innymi-wzorcami","text":"Powiązania z innymi wzorcami","level":2,"locked":true},{"id":"w-praktyce","text":"W praktyce","level":2,"locked":true},{"id":"sprawdz-sie","text":"Sprawdź się","level":2,"locked":true}],"locked":true,"paywall":null,"previewRatio":0.3,"totalBlocks":35,"visibleBlocks":15,"resources":[{"id":"6b0857bf3c96f2d34d0b42cc","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/mediator","embedUrl":null,"title":"Mediator / Mediator","description":"Mediator to behawioralny wzorzec projektowy pozwalający zredukować chaos zależności pomiędzy obiektami. Wzorzec ten ogranicza bezpośrednią komunikację pomiędzy obiektami i zmusza je do współpracy wyłącznie za pośrednictwem obiektu mediatora","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["mediator"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":60,"verifiedAt":"2026-11-26T11:26:12.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857c63c96f2d34d0b48c7","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=2xiHO1tv4Cc","embedUrl":"https://www.youtube-nocookie.com/embed/2xiHO1tv4Cc","title":"No, You Really Don't Need MediatR in .NET","description":"Online Workshop: Vibe Coding for Production: https://dometrain.com/workshop/vibe-coding-for-production/?ref=nick-chapsas&promo=mail-list&coupon_code=3YEARS Get every Dometrain 40% off with code 3YEARS: https://dometrain.com/courses/?ref=nick-chapsas&promo=youtube&coupon_code=3YEARS Hello…","author":"Nick Chapsas","thumbnailUrl":"https://i.ytimg.com/vi/2xiHO1tv4Cc/hqdefault.jpg","durationSec":null,"lang":"en","topics":["ai-coding-assistants","ai-in-dotnet"],"techs":["dotnet"],"tags":["ai"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2026-05-20T12:30:34.000Z","popularity":69,"verifiedAt":"2026-11-26T10:54:20.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"},{"id":"6b0857c03c96f2d34d0b43e9","type":"article","provider":"web","url":"https://milanjovanovic.tech/blog/stop-conflating-cqrs-and-mediatr","embedUrl":null,"title":"CQRS vs MediatR: Do You Need MediatR?","description":"The .NET ecosystem has fused CQRS and MediatR together, and that shortcut leads teams into unnecessary complexity. They solve different problems.","author":"Milan Jovanović","thumbnailUrl":"https://milanjovanovic.tech/blog-covers/mnw_128.png","durationSec":null,"lang":"en","topics":["cqrs"],"techs":["dotnet"],"tags":["software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":"2025-02-08T00:00:00.000Z","popularity":50,"verifiedAt":"2026-11-26T11:29:03.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857b23c96f2d34d0b3484","type":"repo","provider":"github","url":"https://github.com/LuckyPennySoftware/MediatR","embedUrl":null,"title":"LuckyPennySoftware/MediatR","description":"Simple, unambitious mediator implementation in .NET","author":"LuckyPennySoftware","thumbnailUrl":"https://opengraph.githubassets.com/1/LuckyPennySoftware/MediatR","durationSec":null,"lang":"en","topics":["mediator","cqrs"],"techs":["dotnet"],"tags":["hacktoberfest","design-patterns","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"github","publishedAt":"2014-03-03T15:01:22.000Z","popularity":79,"verifiedAt":"2026-11-26T10:55:56.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:49.541Z","updatedAt":"2026-11-26T16:00:49.541Z"}],"challenges":[{"id":"6b093dc191bd8fbaf2a0c8d0","slug":"inventory-cqrs","title":"Magazyn z CQRS – osobny model zapisu i odczytu","summary":"Komendy magazynowe walidowane na własnym modelu zapisu, zdarzenia na szynie i projekcja budująca model odczytu z raportem niskich stanów. Model odczytu da się odtworzyć z samych zdarzeń.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"architecture","status":"published","difficulty":"medium","topics":["cqrs","event-driven-architecture"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["cqrs","read-model","projection","events","inventory"],"languages":["typescript","javascript","python","csharp","java","go"],"questionCount":null,"xp":20,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:25.519Z"},{"id":"6b093dc091bd8fbaf2a0c8c0","slug":"event-sourced-account","title":"Konto bankowe w event sourcingu","summary":"Agregat konta, którego stan powstaje wyłącznie z odtwarzania zdarzeń, magazyn zdarzeń z optymistyczną współbieżnością i repozytorium zapisujące tylko nowe fakty. Zapytania o stan z przeszłości w gratisie.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"architecture","status":"published","difficulty":"hard","topics":["event-sourcing","cqrs"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["event-sourcing","aggregate","event-store","optimistic-concurrency","ddd"],"languages":["typescript","javascript","python","csharp","java","go"],"questionCount":null,"xp":40,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:24.935Z"}],"attachments":[],"hasCode":true,"repoUrl":null,"series":[{"slug":"gof-behavioral","title":"Wzorce behawioralne GoF","items":[{"slug":"strategy","title":"Strategia (Strategy): wymienne algorytmy zamiast drabinki if-ów","current":false},{"slug":"observer","title":"Obserwator (Observer): powiadom wszystkich, nie znając nikogo","current":false},{"slug":"command","title":"Polecenie (Command): żądanie zamknięte w obiekcie","current":false},{"slug":"state","title":"Stan (State): obiekt, który zmienia zachowanie razem z etapem życia","current":false},{"slug":"template-method","title":"Metoda szablonowa (Template Method): stały przepis, wymienne składniki","current":false},{"slug":"iterator","title":"Iterator: przechodzenie po kolekcji bez zaglądania do środka","current":false},{"slug":"chain-of-responsibility","title":"Łańcuch zobowiązań (Chain of Responsibility): podaj dalej, aż ktoś się zajmie","current":false},{"slug":"mediator","title":"Mediator: komponenty rozmawiają przez koordynatora","current":true},{"slug":"memento","title":"Pamiątka (Memento): migawka stanu bez łamania hermetyzacji","current":false},{"slug":"visitor","title":"Odwiedzający (Visitor): nowe operacje bez zmiany klas","current":false}]}],"prev":{"slug":"chain-of-responsibility","title":"Łańcuch zobowiązań (Chain of Responsibility): podaj dalej, aż ktoś się zajmie"},"next":{"slug":"memento","title":"Pamiątka (Memento): migawka stanu bez łamania hermetyzacji"},"featured":false,"authorCard":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","headline":"Wzorce projektowe · Architektura · AI i LLM","community":false,"reputation":{"points":3900,"level":{"key":"mentor","label":"Mentor"}},"articles":68,"skills":[{"key":"typescript","title":"TypeScript","level":5,"levelLabel":"Autorytet","articles":63},{"key":"dotnet","title":".NET","level":5,"levelLabel":"Autorytet","articles":53},{"key":"python","title":"Python","level":5,"levelLabel":"Autorytet","articles":52},{"key":"java","title":"Java","level":5,"levelLabel":"Autorytet","articles":38}]}}