{"id":"6b093dc091bd8fbaf2a0c8b2","slug":"specification","title":"Specyfikacja: reguły biznesowe jako obiekty, które się składa","summary":"Wzorzec Specyfikacja z Domain-Driven Design: nazwane reguły z isSatisfiedBy, łączenie przez and, or i not, ta sama reguła do walidacji i zapytań, tłumaczenie na SQL przez drzewa wyrażeń, Criteria API i Q. Kod w C#, TypeScript, Javie, Go i Pythonie.","servedLang":"pl","availableLangs":["pl","en"],"topics":["specification","composite","ddd-strategic-design"],"techs":["dotnet","typescript","java","go","python"],"tags":["ddd","specification","business-rules","repository","expression-trees","tactical-patterns"],"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":12,"stats":{"views":1,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-27T08:22:24.343Z","updatedAt":"2026-11-27T10:04:40.031Z","requestedLang":"pl","theme":{"hero":"classic","heroMedia":null,"accent":"teal","background":"hex","weaveResources":true,"toc":"right"},"seoDescription":"Specification pattern (DDD): isSatisfiedBy, kombinatory and/or/not, walidacja i wybór z repozytorium, Expression<Func<T,bool>> w EF Core, Spring Data JPA Specification, Django Q, Ardalis.Specification, przykłady w C#, TypeScript, Java, Go i Python.","wordCount":2233,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Hurtownia sprzedaje firmom na kredyt kupiecki: płatność 30 dni po dostawie. Reguła „kto może kupić z odroczonym terminem” brzmi prosto – zweryfikowana firma, bez przeterminowanych faktur, co najmniej sześć zamówień w ostatnim roku – ale żyje w czterech miejscach: w koszyku, w panelu handlowca, w zapytaniu do kampanii mailowej i w raporcie dla działu finansów. Każda kopia jest odrobinę inna. "},{"type":"text","text":"Specyfikacja","marks":[{"type":"bold"}]},{"type":"text","text":" (ang. "},{"type":"text","text":"Specification","marks":[{"type":"italic"}]},{"type":"text","text":") robi z takiej reguły obiekt z nazwą z języka domeny, który odpowiada na jedno pytanie: czy ten kandydat ją spełnia?"}]},{"type":"callout","attrs":{"variant":"tip","title":"W skrócie"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Specyfikacja to "},{"type":"text","text":"predykat z nazwą biznesową","marks":[{"type":"bold"}]},{"type":"text","text":" – metoda "},{"type":"text","text":"isSatisfiedBy(candidate)","marks":[{"type":"code"}]},{"type":"text","text":" zwraca "},{"type":"text","text":"true","marks":[{"type":"code"}]},{"type":"text","text":" albo "},{"type":"text","text":"false","marks":[{"type":"code"}]},{"type":"text","text":"."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Małe reguły łączy się operatorami "},{"type":"text","text":"and, or, not","marks":[{"type":"bold"}]},{"type":"text","text":" w nowe specyfikacje – powstaje drzewo, czyli Kompozyt."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Ta sama specyfikacja służy do "},{"type":"text","text":"walidacji","marks":[{"type":"bold"}]},{"type":"text","text":" pojedynczego obiektu i do "},{"type":"text","text":"wyboru","marks":[{"type":"bold"}]},{"type":"text","text":" obiektów z repozytorium – a z drzewem wyrażeń także do zapytania SQL."}]}]}]}]},{"type":"stats","attrs":{"items":[{"value":"2003","label":"„Domain-Driven Design”","hint":"Eric Evans opisuje Specyfikację wśród wzorców ujawniających ukryte pojęcia"},{"value":"3","label":"zastosowania według Evansa","hint":"walidacja, wybór z kolekcji, budowanie obiektów na zamówienie"},{"value":"3","label":"kombinatory","hint":"and, or, not – i żadnych nowych metod w repozytorium"}]}},{"type":"heading","attrs":{"level":2,"id":"problem-regula-rozsiana-po-kodzie"},"content":[{"type":"text","text":"Problem: reguła rozsiana po kodzie"}]},{"type":"paragraph","content":[{"type":"text","text":"Tak wyglądała reguła kredytu kupieckiego po dwóch latach rozwoju:"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"trade-credit.before.ts"},"content":[{"type":"text","text":"// checkout\nfunction canBuyOnCredit(c: Customer): boolean {\n  return c.verified && c.taxId != null && c.overdueInvoices === 0 && c.ordersLastYear >= 6;\n}\n\n// e-mail campaign – copied, but someone \"simplified\" it and the SQL drifted away from the code above\nconst audience = await db.query(\n  \"SELECT * FROM customers WHERE verified = true AND orders_last_year >= 5\", // taxId? overdue invoices?\n);\n\n// sales panel – yet another variant, with an extra exception nobody remembers\nconst eligible = customers.filter((c) => (c.verified || c.vip) && c.overdueInvoices === 0);"}]},{"type":"paragraph","content":[{"type":"text","text":"Trzy kopie, trzy różne odpowiedzi na to samo pytanie biznesowe. Kiedy dział finansów podniesie próg do ośmiu zamówień, ktoś zmieni jedno miejsce z trzech. Do tego reguła nie ma nazwy – w kodzie widać warunki, ale nie widać pojęcia „klient uprawniony do kredytu kupieckiego”."}]},{"type":"heading","attrs":{"level":2,"id":"rozwiazanie-nazwane-reguly-i-kombinatory"},"content":[{"type":"text","text":"Rozwiązanie: nazwane reguły i kombinatory"}]},{"type":"paragraph","content":[{"type":"text","text":"Każdy warunek staje się osobną specyfikacją: "},{"type":"text","text":"VerifiedCompany","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"HasOverdueInvoices","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"RegularBuyer","marks":[{"type":"code"}]},{"type":"text","text":". Wspólny interfejs ma metodę "},{"type":"text","text":"isSatisfiedBy","marks":[{"type":"code"}]},{"type":"text","text":" oraz kombinatory, które zwracają "},{"type":"text","text":"nowe","marks":[{"type":"bold"}]},{"type":"text","text":" specyfikacje. Polityka kredytowa to po prostu złożenie: "},{"type":"text","text":"VerifiedCompany and not HasOverdueInvoices and RegularBuyer","marks":[{"type":"code"}]},{"type":"text","text":". Koszyk pyta o jednego klienta, kampania – o wszystkich, ale obie korzystają z tego samego obiektu."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"classDiagram\n  direction LR\n  class Specification~T~ {\n    <<interface>>\n    +isSatisfiedBy(candidate) bool\n    +and(other) Specification\n    +or(other) Specification\n    +not() Specification\n  }\n  class AndSpecification\n  class OrSpecification\n  class NotSpecification\n  class VerifiedCompany\n  class HasOverdueInvoices\n  class RegularBuyer\n  Specification <|.. AndSpecification\n  Specification <|.. OrSpecification\n  Specification <|.. NotSpecification\n  Specification <|.. VerifiedCompany\n  Specification <|.. HasOverdueInvoices\n  Specification <|.. RegularBuyer\n  AndSpecification o-- \"2\" Specification\n  OrSpecification o-- \"2\" Specification\n  NotSpecification o-- \"1\" Specification\n  CheckoutService ..> Specification : waliduje klienta\n  CustomerRepository ..> Specification : wybiera klientów","caption":"Specyfikacje liściowe i kombinatory mają wspólny interfejs – klient nie odróżnia reguły prostej od złożonej"}},{"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":"Odpowiedzialność"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"W przykładzie"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Specyfikacja"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"interfejs: "},{"type":"text","text":"isSatisfiedBy","marks":[{"type":"code"}]},{"type":"text","text":" + kombinatory"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Specification<T>","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Specyfikacja liściowa"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"jedna reguła biznesowa z nazwą"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"VerifiedCompany","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"HasOverdueInvoices","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Kombinator"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"łączy specyfikacje logicznie, sam też jest specyfikacją"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"And","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Or","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Not","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Klient"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"używa specyfikacji do walidacji, wyboru lub budowania"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"koszyk, repozytorium, kampania"}]}]}]}]},{"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":"Wersja C# opiera specyfikację na drzewie wyrażeń ("},{"type":"text","text":"Expression<Func<T, bool>>","marks":[{"type":"code"}]},{"type":"text","text":"), więc EF Core przetłumaczy ją na SQL. TypeScript i Go pokazują styl funkcyjny z nazwami reguł, dzięki którym da się powiedzieć klientowi, "},{"type":"text","text":"dlaczego","marks":[{"type":"italic"}]},{"type":"text","text":" odmówiono. Java korzysta z gotowej "},{"type":"text","text":"Specification<T>","marks":[{"type":"code"}]},{"type":"text","text":" ze Spring Data JPA, a Python – z przeciążonych operatorów i obiektów "},{"type":"text","text":"Q","marks":[{"type":"code"}]},{"type":"text","text":"/"},{"type":"text","text":"Exists","marks":[{"type":"code"}]},{"type":"text","text":" z Django."}]},{"type":"codeGroup","attrs":{"title":"Polityka kredytu kupieckiego"},"content":[{"type":"codeBlock","attrs":{"language":"csharp","filename":"TradeCreditSpecs.cs"},"content":[{"type":"text","text":"// A specification wraps an expression tree, so EF Core can translate it to SQL.\npublic abstract class Specification<T>\n{\n    private Func<T, bool>? _compiled;\n\n    public abstract Expression<Func<T, bool>> ToExpression();\n\n    // In memory: compile once and reuse – compiling on every call is expensive.\n    public bool IsSatisfiedBy(T candidate) => (_compiled ??= ToExpression().Compile())(candidate);\n\n    public Specification<T> And(Specification<T> other) => new Binary(this, other, Expression.AndAlso);\n    public Specification<T> Or(Specification<T> other) => new Binary(this, other, Expression.OrElse);\n    public Specification<T> Not() => new Negation(this);\n\n    private sealed class Binary(Specification<T> left, Specification<T> right,\n        Func<Expression, Expression, BinaryExpression> combine) : Specification<T>\n    {\n        public override Expression<Func<T, bool>> ToExpression()\n        {\n            var l = left.ToExpression();\n            var r = right.ToExpression();\n            var rightBody = new SwapParameter(r.Parameters[0], l.Parameters[0]).Visit(r.Body); // x => l(x) && r(x)\n            return Expression.Lambda<Func<T, bool>>(combine(l.Body, rightBody), l.Parameters);\n        }\n    }\n\n    private sealed class Negation(Specification<T> inner) : Specification<T>\n    {\n        public override Expression<Func<T, bool>> ToExpression()\n        {\n            var e = inner.ToExpression();\n            return Expression.Lambda<Func<T, bool>>(Expression.Not(e.Body), e.Parameters);\n        }\n    }\n\n    private sealed class SwapParameter(ParameterExpression from, ParameterExpression to) : ExpressionVisitor\n    {\n        protected override Expression VisitParameter(ParameterExpression node) => node == from ? to : node;\n    }\n}\n\npublic sealed class VerifiedCompany : Specification<Customer>\n{\n    public override Expression<Func<Customer, bool>> ToExpression() => c => c.Verified && c.TaxId != null;\n}\n\npublic sealed class HasOverdueInvoices : Specification<Customer>\n{\n    public override Expression<Func<Customer, bool>> ToExpression() =>\n        c => c.Invoices.Any(i => !i.Paid && i.DueDate < DateTime.UtcNow);\n}\n\n// The same rule validates one customer and selects customers in the database:\n//   var policy = new VerifiedCompany().And(new HasOverdueInvoices().Not());\n//   if (!policy.IsSatisfiedBy(customer)) throw new TradeCreditRefused(customer.Id);\n//   var audience = await db.Customers.Where(policy.ToExpression()).ToListAsync(ct);"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"trade-credit-specs.ts"},"content":[{"type":"text","text":"// A specification is a named predicate; combinators build new specifications from existing ones.\nexport interface Spec<T> {\n  readonly name: string;\n  isSatisfiedBy(candidate: T): boolean;\n}\n\nexport const spec = <T>(name: string, test: (c: T) => boolean): Spec<T> => ({ name, isSatisfiedBy: test });\n\nexport const and = <T>(...specs: Spec<T>[]): Spec<T> =>\n  spec(specs.map((s) => s.name).join(\" AND \"), (c) => specs.every((s) => s.isSatisfiedBy(c)));\n\nexport const or = <T>(...specs: Spec<T>[]): Spec<T> =>\n  spec(specs.map((s) => s.name).join(\" OR \"), (c) => specs.some((s) => s.isSatisfiedBy(c)));\n\nexport const not = <T>(s: Spec<T>): Spec<T> => spec(`NOT (${s.name})`, (c) => !s.isSatisfiedBy(c));\n\n/** Names of the rules the candidate fails – ready for an error message or a UI hint. */\nexport const unmet = <T>(candidate: T, ...specs: Spec<T>[]): string[] =>\n  specs.filter((s) => !s.isSatisfiedBy(candidate)).map((s) => s.name);\n\ninterface Customer {\n  verified: boolean;\n  taxId?: string;\n  overdueInvoices: number;\n  ordersLastYear: number;\n}\n\nexport const verifiedCompany = spec<Customer>(\"verified company\", (c) => c.verified && !!c.taxId);\nexport const noOverdueInvoices = spec<Customer>(\"no overdue invoices\", (c) => c.overdueInvoices === 0);\nexport const regularBuyer = spec<Customer>(\"6+ orders last year\", (c) => c.ordersLastYear >= 6);\n\nconst creditRules = [verifiedCompany, noOverdueInvoices, regularBuyer];\nexport const tradeCreditPolicy = and(...creditRules);\n\nexport function assertTradeCredit(customer: Customer): void {\n  const missing = unmet(customer, ...creditRules); // validation with a reason\n  if (missing.length) throw new Error(`Trade credit refused: ${missing.join(\", \")}`);\n}\n\nexport const creditAudience = (all: Customer[]) => all.filter((c) => tradeCreditPolicy.isSatisfiedBy(c)); // selection"}]},{"type":"codeBlock","attrs":{"language":"java","filename":"CustomerSpecs.java"},"content":[{"type":"text","text":"// Spring Data JPA: a Specification<T> builds a Criteria API predicate, the repository runs it as SQL.\npublic final class CustomerSpecs {\n    private CustomerSpecs() {}\n\n    public static Specification<Customer> verifiedCompany() {\n        return (root, query, cb) -> cb.and(\n            cb.isTrue(root.<Boolean>get(\"verified\")),\n            cb.isNotNull(root.get(\"taxId\")));\n    }\n\n    public static Specification<Customer> hasOverdueInvoices(LocalDate today) {\n        return (root, query, cb) -> {\n            Subquery<Long> overdue = query.subquery(Long.class);\n            Root<Invoice> invoice = overdue.from(Invoice.class);\n            overdue.select(cb.literal(1L)).where(\n                cb.equal(invoice.get(\"customer\"), root),\n                cb.isFalse(invoice.<Boolean>get(\"paid\")),\n                cb.lessThan(invoice.<LocalDate>get(\"dueDate\"), today));\n            return cb.exists(overdue);\n        };\n    }\n\n    public static Specification<Customer> placedAtLeast(int orders) {\n        return (root, query, cb) -> cb.greaterThanOrEqualTo(root.<Integer>get(\"ordersLastYear\"), orders);\n    }\n}\n\npublic interface CustomerRepository extends JpaRepository<Customer, Long>, JpaSpecificationExecutor<Customer> {}\n\n@Service\nclass TradeCreditService {\n    private final CustomerRepository customers;\n    private final Clock clock;\n\n    TradeCreditService(CustomerRepository customers, Clock clock) {\n        this.customers = customers;\n        this.clock = clock;\n    }\n\n    List<Customer> creditAudience() {\n        Specification<Customer> policy = CustomerSpecs.verifiedCompany()\n            .and(Specification.not(CustomerSpecs.hasOverdueInvoices(LocalDate.now(clock))))\n            .and(CustomerSpecs.placedAtLeast(6));\n        return customers.findAll(policy); // one SQL query with EXISTS, nothing filtered in memory\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"go","filename":"specs.go"},"content":[{"type":"text","text":"package credit\n\nimport \"strings\"\n\n// Spec is a named business rule; generics (Go 1.18+) make the combinators reusable for any type.\ntype Spec[T any] struct {\n\tName string\n\tTest func(T) bool\n}\n\nfunc (s Spec[T]) IsSatisfiedBy(c T) bool { return s.Test(c) }\n\nfunc And[T any](specs ...Spec[T]) Spec[T] {\n\tnames := make([]string, len(specs))\n\tfor i, s := range specs {\n\t\tnames[i] = s.Name\n\t}\n\treturn Spec[T]{Name: strings.Join(names, \" AND \"), Test: func(c T) bool {\n\t\tfor _, s := range specs {\n\t\t\tif !s.Test(c) {\n\t\t\t\treturn false // short-circuit like &&\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}}\n}\n\nfunc Not[T any](s Spec[T]) Spec[T] {\n\treturn Spec[T]{Name: \"NOT (\" + s.Name + \")\", Test: func(c T) bool { return !s.Test(c) }}\n}\n\n// Unmet returns the names of the rules the candidate fails – handy for error messages.\nfunc Unmet[T any](c T, specs ...Spec[T]) []string {\n\tvar failed []string\n\tfor _, s := range specs {\n\t\tif !s.Test(c) {\n\t\t\tfailed = append(failed, s.Name)\n\t\t}\n\t}\n\treturn failed\n}\n\ntype Customer struct {\n\tVerified        bool\n\tTaxID           string\n\tOverdueInvoices int\n\tOrdersLastYear  int\n}\n\nvar (\n\tVerifiedCompany   = Spec[Customer]{\"verified company\", func(c Customer) bool { return c.Verified && c.TaxID != \"\" }}\n\tNoOverdueInvoices = Spec[Customer]{\"no overdue invoices\", func(c Customer) bool { return c.OverdueInvoices == 0 }}\n\tRegularBuyer      = Spec[Customer]{\"6+ orders last year\", func(c Customer) bool { return c.OrdersLastYear >= 6 }}\n\tTradeCreditPolicy = And(VerifiedCompany, NoOverdueInvoices, RegularBuyer)\n)"}]},{"type":"codeBlock","attrs":{"language":"python","filename":"specs.py"},"content":[{"type":"text","text":"from __future__ import annotations\n\nfrom dataclasses import dataclass\nfrom typing import Callable, Generic, TypeVar\n\nT = TypeVar(\"T\")\n\n\n@dataclass(frozen=True)\nclass Spec(Generic[T]):\n    \"\"\"A named business rule; &, | and ~ build new specifications.\"\"\"\n\n    name: str\n    test: Callable[[T], bool]\n\n    def is_satisfied_by(self, candidate: T) -> bool:\n        return self.test(candidate)\n\n    def __and__(self, other: Spec[T]) -> Spec[T]:\n        return Spec(f\"{self.name} AND {other.name}\", lambda c: self.test(c) and other.test(c))\n\n    def __or__(self, other: Spec[T]) -> Spec[T]:\n        return Spec(f\"{self.name} OR {other.name}\", lambda c: self.test(c) or other.test(c))\n\n    def __invert__(self) -> Spec[T]:\n        return Spec(f\"NOT ({self.name})\", lambda c: not self.test(c))\n\n\n@dataclass\nclass Customer:\n    verified: bool\n    tax_id: str | None\n    overdue_invoices: int\n    orders_last_year: int\n\n\nverified_company = Spec[Customer](\"verified company\", lambda c: c.verified and c.tax_id is not None)\nno_overdue_invoices = Spec[Customer](\"no overdue invoices\", lambda c: c.overdue_invoices == 0)\nregular_buyer = Spec[Customer](\"6+ orders last year\", lambda c: c.orders_last_year >= 6)\ntrade_credit_policy = verified_company & no_overdue_invoices & regular_buyer\n\n# Django ORM: Q and Exists are specifications the ORM translates to SQL.\n#   overdue = Invoice.objects.filter(customer=OuterRef(\"pk\"), paid=False, due_date__lt=today)\n#   audience = Customer.objects.filter(Q(verified=True, tax_id__isnull=False, orders_last_year__gte=6), ~Exists(overdue))"}]}]}]},"toc":[{"id":"problem-regula-rozsiana-po-kodzie","text":"Problem: reguła rozsiana po kodzie","level":2,"locked":false},{"id":"rozwiazanie-nazwane-reguly-i-kombinatory","text":"Rozwiązanie: nazwane reguły i kombinatory","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":"kiedy-stosowac-a-kiedy-nie","text":"Kiedy stosować, a kiedy nie","level":2,"locked":true},{"id":"powiazane-wzorce","text":"Powiązane wzorce","level":2,"locked":true},{"id":"w-praktyce","text":"W praktyce","level":2,"locked":true},{"id":"sprawdz-sie","text":"Sprawdź się","level":2,"locked":true},{"id":"zadanie-praktyczne","text":"Zadanie praktyczne","level":2,"locked":true}],"locked":true,"paywall":null,"previewRatio":0.3,"totalBlocks":34,"visibleBlocks":14,"resources":[{"id":"6b0857b23c96f2d34d0b35a2","type":"repo","provider":"github","url":"https://github.com/ardalis/Specification","embedUrl":null,"title":"ardalis/Specification","description":"Base class with tests for adding specifications to a DDD model","author":"ardalis","thumbnailUrl":"https://opengraph.githubassets.com/1/ardalis/Specification","durationSec":null,"lang":"en","topics":["ddd-strategic-design"],"techs":["dotnet"],"tags":["ddd","design-patterns","domain-driven-design","dotnet","hacktoberfest","repository-pattern","testing","specification-pattern","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"github","publishedAt":"2018-02-13T16:42:06.000Z","popularity":65,"verifiedAt":"2026-11-26T10:58:11.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:50.215Z","updatedAt":"2026-11-26T16:00:50.215Z"},{"id":"6b0857be3c96f2d34d0b41dc","type":"article","provider":"web","url":"https://www.domainlanguage.com/ddd/reference","embedUrl":null,"title":"DDD Reference - Domain Language","description":"A summary of the patterns and definitions of DDD. This document is meant as a convenient reference for those who know the principles of Domain-Driven Design (DDD). It does not contain full explanations of DDD or even of the terms and patterns covered. It is intended to be used as a complement to…","author":"Domain Language (Eric Evans)","thumbnailUrl":"https://domainlanguage.com/wp-content/uploads/2016/04/71QA9u88PdL-194x300.jpg","durationSec":null,"lang":"en","topics":["ddd-strategic-design"],"techs":["general"],"tags":["software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":80,"verifiedAt":"2026-11-26T11:26:00.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857c33c96f2d34d0b4669","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL4464385W","embedUrl":null,"title":"Domain-Driven Design","description":"","author":"Eric Evans","thumbnailUrl":"https://covers.openlibrary.org/b/id/5548424-L.jpg","durationSec":null,"lang":"en","topics":["ddd-strategic-design"],"techs":["general"],"tags":["book","software-architecture"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"2003-01-01T00:00:00.000Z","popularity":61,"verifiedAt":"2026-11-26T11:00:08.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:04.995Z","updatedAt":"2026-11-26T16:01:04.995Z"},{"id":"6b0857be3c96f2d34d0b41f2","type":"article","provider":"web","url":"https://martinfowler.com/bliki/EvansClassification.html","embedUrl":null,"title":"bliki: Evans Classification","description":"a bliki entry for Evans Classification","author":"Martin Fowler","thumbnailUrl":"https://martinfowler.com/logo-sq.png","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["martin-fowler"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":75,"verifiedAt":"2026-11-26T11:07:28.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857b23c96f2d34d0b3463","type":"repo","provider":"github","url":"https://github.com/Sairyss/domain-driven-hexagon","embedUrl":null,"title":"Sairyss/domain-driven-hexagon","description":"Learn Domain-Driven Design, software architecture, design patterns, best practices. Code examples included","author":"Sairyss","thumbnailUrl":"https://opengraph.githubassets.com/1/Sairyss/domain-driven-hexagon","durationSec":null,"lang":"en","topics":["solid","clean-architecture","hexagonal-architecture","onion-architecture","ddd-strategic-design"],"techs":["node","javascript","typescript"],"tags":["architectural-patterns","architecture","backend","best-practices","clean-architecture","clean-code","design-patterns","software-architecture","system-design","ddd"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"github","publishedAt":"2020-11-29T16:04:22.000Z","popularity":81,"verifiedAt":"2026-11-26T10:58:46.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:49.541Z","updatedAt":"2026-11-26T16:00:49.541Z"}],"challenges":[{"id":"6b093dc091bd8fbaf2a0c8bc","slug":"catalog-specification","title":"Specyfikacje w katalogu sklepu","summary":"Reguły promocji jako małe obiekty, które się składa operatorami and, or i not – wzorzec Specyfikacja z DDD, własne reguły i wyszukiwanie w katalogu.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"pattern","status":"published","difficulty":"medium","topics":["specification"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["specification","ddd","composite","business-rules","e-commerce"],"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:24.795Z"},{"id":"6b093ddebd4755deb67ee06e","slug":"flatten-object","title":"Spłaszczanie zagnieżdżonego obiektu","summary":"Zamieniamy zagnieżdżony obiekt JSON na płaską mapę ścieżka → wartość (np. do eksportu CSV albo porównania konfiguracji). Rekurencja lub jawny stos, liście i puste kontenery.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"algorithms","status":"published","difficulty":"easy","topics":["composite"],"techs":["typescript","javascript","python"],"tags":["recursion","objects","dfs","javascript"],"languages":["typescript","javascript","python"],"questionCount":null,"xp":10,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:54.109Z"},{"id":"6b0857af5a2625e44ecaad13","slug":"design-patterns-basics-quiz","title":"Wzorce projektowe – podstawy","summary":"Sześć pytań o klasyczne wzorce GoF: grupy, przeznaczenie i różnice.","servedLang":"pl","availableLangs":["pl","en"],"kind":"quiz","category":null,"status":"published","difficulty":"easy","topics":["builder","adapter","strategy","decorator","composite","facade","observer"],"techs":["general"],"tags":["quiz","gof","basics"],"languages":[],"questionCount":6,"xp":10,"stats":{"attempts":1,"solves":1,"solutions":0,"comments":0},"solveRate":100,"publishedAt":"2026-11-26T16:00:47.960Z"}],"attachments":[],"hasCode":true,"repoUrl":null,"series":[],"prev":null,"next":null,"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}]}}