docs: teach the composition root and DI anti-patterns#97
Conversation
🚀 Benchmark ResultsDetails
Details
Details
|
Add Docs/pages/02-principles.md, a design-focused page that sits after getting-started. The feature pages teach the mechanics Awaiten enforces (lifetimes, cycles, async); this page teaches the design those mechanics serve, which no tool can enforce. It covers what DI is really for, the composition root and the domain-must-not-reference-Awaiten rule, volatile vs. stable dependencies with a decision rule, the four anti-patterns (Control Freak, Service Locator, Ambient Context, Constrained Construction) each with an "In Awaiten" note, keeping DI out of the domain via the container-side idioms, and when a powerful feature is smoothing over a design that wants to be split. Reflect the current attribute surface rather than the original issue text: [FromServices] is gone in favor of the container-side [ImportService<T>], so the escape hatches are the three consumer-side attributes [Arg], [FromKey], and [Inject]. The Service Locator note states the rule and frames boundary enforcement as a recommended architecture test, since the analyzer for it is not shipped. Link the page from the docs index and the README, and add a "When not to reach for this" caution to keyed-services, scanning, property-injection, and context-aware-factories, each pointing back to the principles page.
The composition-boundary and service-locator anti-patterns are now enforced by suppressible analyzer warnings, so update the two "not enforced yet" notes on the principles page. The Service Locator rule now points at AWT135 (holding a resolver in anything but the [Container]); the boundary note points at AWT134 (a composition attribute in an assembly that declares no [Container]) and keeps the architecture test as the complementary cross-assembly enforcement, since AWT134 is a best-effort in-assembly guard.
b061755 to
172030d
Compare
…ystem - attribute the four anti-patterns to van Deursen & Seemann's book and Seemann's blog; re-theme the examples to the coffee shop - replace the vague 'the book' phrasing with a concrete aweXpect.Reflection architecture test asserting the domain carries no reference to Awaiten - add that test to Awaiten.ExampleTests over a clean CoffeeShop domain (aweXpect.Reflection 2.0.0), verified red on a violation - swap IClock for Testably's ITimeSystem throughout the doc examples - insert principles at sidebar position 2 and shift the rest by one
- link the composition root and Pure DI posts where each concept appears - back the opinionated claims with Fowler, Microsoft DI guidelines, and the dependency-inversion / explicit-dependencies principles, not just Seemann - rewrite the four-anti-patterns intro to lead with substance over attribution - replace all em-dashes with colons, sentence breaks, or parentheses
|
… anti-patterns (#97) by Valentin Breuß
… anti-patterns (#97) by Valentin Breuß
|
This is addressed in release v0.4.0. |



Add Docs/pages/02-principles.md, a design-focused page that sits after getting-started. The feature pages teach the mechanics Awaiten enforces (lifetimes, cycles, async); this page teaches the design those mechanics serve, which no tool can enforce. It covers what DI is really for, the composition root and the domain-must-not-reference-Awaiten rule, volatile vs. stable dependencies with a decision rule, the four anti-patterns (Control Freak, Service Locator, Ambient Context, Constrained Construction) each with an "In Awaiten" note, keeping DI out of the domain via the container-side idioms, and when a powerful feature is smoothing over a design that wants to be split.
Reflect the current attribute surface rather than the original issue text: [FromServices] is gone in favor of the container-side [ImportService], so the escape hatches are the three consumer-side attributes [Arg], [FromKey], and [Inject]. The Service Locator note states the rule and frames boundary enforcement as a recommended architecture test, since the analyzer for it is not shipped.
Link the page from the docs index and the README, and add a "When not to reach for this" caution to keyed-services, scanning, property-injection, and context-aware-factories, each pointing back to the principles page.