@hobin/developer 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +215 -372
- package/REFERENCE_ROUTING.md +243 -0
- package/extensions/developer.ts +533 -18
- package/extensions/machine.ts +45 -0
- package/extensions/references/behavior-preserving-structural-change.md +87 -8
- package/extensions/skills.ts +330 -52
- package/extensions/state.ts +227 -2
- package/package.json +9 -3
- package/skills/abstraction-review/SKILL.md +37 -23
- package/skills/abstraction-review/reference-policy.json +66 -0
- package/skills/abstraction-review/references/field-card.md +113 -168
- package/skills/abstraction-review/references/repair-table.md +66 -80
- package/skills/abstraction-review/references/worked-examples.md +79 -256
- package/skills/model/SKILL.md +31 -13
- package/skills/model/reference-policy.json +96 -0
- package/skills/model/references/contract-and-replacement-models.md +112 -0
- package/skills/model/references/logic-query-semantics.md +89 -0
- package/skills/model/references/planning-models.md +75 -0
- package/skills/model/references/problem-modeling.md +143 -276
- package/skills/model/references/proof-obligations.md +71 -0
- package/skills/model/references/relational-constraint-models.md +110 -0
- package/skills/model/references/solver-result-boundaries.md +83 -0
- package/skills/model/references/temporal-behavior-models.md +106 -0
- package/skills/naming-judgment/SKILL.md +17 -4
- package/skills/naming-judgment/reference-policy.json +29 -0
- package/skills/naming-judgment/references/domain-naming.md +29 -10
- package/skills/schedule/SKILL.md +16 -6
- package/skills/schedule/reference-policy.json +29 -0
- package/skills/schedule/references/structural-change-timing.md +81 -18
- package/skills/signal/SKILL.md +17 -6
- package/skills/signal/reference-policy.json +29 -0
- package/skills/signal/references/structural-movement.md +87 -14
- package/skills/sketch/SKILL.md +38 -42
- package/skills/sketch/reference-policy.json +212 -0
- package/skills/sketch/references/accumulator-invariants.md +125 -0
- package/skills/sketch/references/closure-and-conventional-interfaces.md +87 -0
- package/skills/sketch/references/composition-by-wishes.md +69 -0
- package/skills/sketch/references/data-driven-design.md +99 -22
- package/skills/sketch/references/data-shape-template-catalog.md +58 -19
- package/skills/sketch/references/design-levels-and-boundaries.md +133 -0
- package/skills/sketch/references/earned-abstraction.md +75 -0
- package/skills/sketch/references/generative-recursion.md +122 -0
- package/skills/sketch/references/generic-dispatch-systems.md +75 -0
- package/skills/sketch/references/language-semantics.md +82 -0
- package/skills/sketch/references/meaning-preserving-conversions.md +69 -0
- package/skills/sketch/references/process-shape-and-resources.md +157 -0
- package/skills/sketch/references/representation-barriers.md +73 -0
- package/skills/sketch/references/responsibility-and-collaboration.md +108 -0
- package/skills/sketch/references/runtime-and-compilation.md +84 -0
- package/skills/sketch/references/selection-and-creation.md +76 -0
- package/skills/sketch/references/state-history-and-order.md +126 -0
- package/skills/sketch/references/type-transitions.md +54 -0
- package/skills/sketch/references/variation-roles.md +59 -0
- package/skills/verify/SKILL.md +17 -6
- package/skills/verify/reference-policy.json +30 -0
- package/skills/verify/references/verifier-selection-and-pass-but-wrong.md +152 -192
- package/SOURCES.md +0 -104
- package/skills/abstraction-review/references/recipe-cards.md +0 -322
- package/skills/model/references/worked-models-and-specialized-techniques.md +0 -218
- package/skills/sketch/references/abstraction-barriers-and-closure.md +0 -160
- package/skills/sketch/references/abstraction-composition-and-state.md +0 -184
- package/skills/sketch/references/composition-generative-recursion-and-accumulators.md +0 -196
- package/skills/sketch/references/generic-operations-and-languages.md +0 -134
- package/skills/sketch/references/processes-state-and-time.md +0 -171
- package/skills/sketch/references/responsibility-and-variation.md +0 -245
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
# Responsibility And Variation
|
|
2
|
-
|
|
3
|
-
Use this reference when a real change exposes misplaced knowledge, repeated
|
|
4
|
-
arguments, data clumps, conditional dispatch, type transitions, object creation,
|
|
5
|
-
or uncertainty about which collaboration should absorb variation.
|
|
6
|
-
|
|
7
|
-
## Begin With The Change
|
|
8
|
-
|
|
9
|
-
Do not design toward classes, polymorphism, or a factory in advance. State the
|
|
10
|
-
accepted change and show where the current code resists it. A smell identifies a
|
|
11
|
-
point of attack, not the final architecture.
|
|
12
|
-
|
|
13
|
-
Keep a simple concrete solution when it remains understandable and cheap to
|
|
14
|
-
change. A more elaborate design is justified by localized future change, not by
|
|
15
|
-
lower line count or the prestige of a pattern.
|
|
16
|
-
|
|
17
|
-
## Inventory Responsibilities
|
|
18
|
-
|
|
19
|
-
Describe what the current unit:
|
|
20
|
-
|
|
21
|
-
- knows;
|
|
22
|
-
- calculates or decides;
|
|
23
|
-
- coordinates;
|
|
24
|
-
- creates;
|
|
25
|
-
- sends to collaborators;
|
|
26
|
-
- changes for independent reasons.
|
|
27
|
-
|
|
28
|
-
Write wishful pseudocode in messages rather than field manipulation. A message
|
|
29
|
-
asks a receiver that owns relevant knowledge to do work. Repeatedly pulling data
|
|
30
|
-
out of one object so another can decide what it means is evidence of misplaced
|
|
31
|
-
responsibility.
|
|
32
|
-
|
|
33
|
-
## Smells As Design Evidence
|
|
34
|
-
|
|
35
|
-
Inspect smells on the accepted change path:
|
|
36
|
-
|
|
37
|
-
- a value repeatedly passed through methods that already belong to one concept;
|
|
38
|
-
- several fields or parameters that move as a data clump;
|
|
39
|
-
- conditionals that select behavior by a stable domain variant;
|
|
40
|
-
- methods that mostly inspect another unit's data;
|
|
41
|
-
- a coordinator that both chooses a variant and implements each variant;
|
|
42
|
-
- object construction mixed into domain collaboration;
|
|
43
|
-
- a chain of navigation that exposes collaborator structure.
|
|
44
|
-
|
|
45
|
-
The sketch should show how one concrete movement would make the change local.
|
|
46
|
-
Do not clean unrelated smells to make the design look complete.
|
|
47
|
-
|
|
48
|
-
## Extracting A Responsibility
|
|
49
|
-
|
|
50
|
-
A candidate unit is credible when data and behavior form a coherent concept with
|
|
51
|
-
its own reason to change. State:
|
|
52
|
-
|
|
53
|
-
```text
|
|
54
|
-
Responsibility: what the unit owns
|
|
55
|
-
Knowledge: data or history required to fulfill it
|
|
56
|
-
Messages: minimal caller-visible protocol
|
|
57
|
-
Hidden detail: mechanics callers stop knowing
|
|
58
|
-
Creation: who constructs or selects it
|
|
59
|
-
Representative change: change that becomes local
|
|
60
|
-
Rejected placement: why the old owner was wrong
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Move callers gradually when old and new forms can coexist. The implementation
|
|
64
|
-
protocol owns those edits; this reference only shapes the target collaboration.
|
|
65
|
-
|
|
66
|
-
Immutability often makes an extracted value easier to share and reason about,
|
|
67
|
-
but it is not mandatory when identity or local history is the product model.
|
|
68
|
-
|
|
69
|
-
## Variation And Substitution
|
|
70
|
-
|
|
71
|
-
Use polymorphism only when variants share a real role and callers can send the
|
|
72
|
-
same message without knowing the concrete type. State the role contract and
|
|
73
|
-
unsupported cases.
|
|
74
|
-
|
|
75
|
-
A subtype or implementation must preserve caller expectations. A special case
|
|
76
|
-
that raises, changes return meaning, or requires stronger preconditions may not
|
|
77
|
-
belong under the common role. Model old and new contracts before claiming safe
|
|
78
|
-
substitution.
|
|
79
|
-
|
|
80
|
-
Conditionals are not categorically wrong. Keep them when the variation is local,
|
|
81
|
-
finite, readable, and unlikely to grow independently. Replace them when new
|
|
82
|
-
accepted variants repeatedly force old behavior owners to change.
|
|
83
|
-
|
|
84
|
-
## Type Transitions
|
|
85
|
-
|
|
86
|
-
When one domain value leads to another kind of value, model the transition as a
|
|
87
|
-
domain relation rather than scattered numeric or string manipulation. State:
|
|
88
|
-
|
|
89
|
-
- current type and next type;
|
|
90
|
-
- operation or event causing the transition;
|
|
91
|
-
- preserved meaning;
|
|
92
|
-
- boundary or terminal behavior;
|
|
93
|
-
- whether the target selects itself or a collaborator decides.
|
|
94
|
-
|
|
95
|
-
Transitions that violate a common role may require a narrower protocol or an
|
|
96
|
-
explicit result type instead of inheritance.
|
|
97
|
-
|
|
98
|
-
## Object Creation And Factories
|
|
99
|
-
|
|
100
|
-
Creation policy belongs at a boundary where variant information is available.
|
|
101
|
-
Keep domain collaborators dependent on the role they use, not on class-name or
|
|
102
|
-
registration mechanics.
|
|
103
|
-
|
|
104
|
-
Factory designs form a continuum: a concrete conditional, configurable mapping,
|
|
105
|
-
registration, self-registration, or automatic discovery each moves knowledge
|
|
106
|
-
and adds operational cost. Compare:
|
|
107
|
-
|
|
108
|
-
- who knows available variants;
|
|
109
|
-
- how a new variant is introduced;
|
|
110
|
-
- unsupported and duplicate registration behavior;
|
|
111
|
-
- load order, reflection, naming, and deployment assumptions;
|
|
112
|
-
- testability and failure visibility.
|
|
113
|
-
|
|
114
|
-
Choose the least powerful mechanism that satisfies real extension pressure.
|
|
115
|
-
Pushing construction to the edge often removes the need for an elaborate
|
|
116
|
-
factory inside the domain.
|
|
117
|
-
|
|
118
|
-
## Dependency Direction And Navigation
|
|
119
|
-
|
|
120
|
-
High-level product behavior should depend on stable roles rather than concrete
|
|
121
|
-
variant mechanics. Inject a dependency when it represents a caller-chosen
|
|
122
|
-
collaborator, not merely to make every object configurable.
|
|
123
|
-
|
|
124
|
-
Long navigation chains reveal structural knowledge. Prefer asking the first
|
|
125
|
-
meaningful collaborator for the domain result, but do not add forwarding methods
|
|
126
|
-
that only hide an unchanged data path. The receiving responsibility must become
|
|
127
|
-
more coherent.
|
|
128
|
-
|
|
129
|
-
## Tests As Role Evidence
|
|
130
|
-
|
|
131
|
-
Choose units to test by public responsibility and cost of failure, not by one
|
|
132
|
-
test file per class. Use integration evidence for collaborations and focused
|
|
133
|
-
unit evidence for stable role contracts or difficult cases.
|
|
134
|
-
|
|
135
|
-
Fakes are useful when they express the same role without importing irrelevant
|
|
136
|
-
context. Tests that echo implementation structure, duplicate the same behavior
|
|
137
|
-
at every layer, or preserve obsolete context inhibit redesign.
|
|
138
|
-
|
|
139
|
-
## Complete Example: Move Discount Knowledge
|
|
140
|
-
|
|
141
|
-
Accepted change: subscriptions now support a partner discount in addition to a
|
|
142
|
-
student discount. Current `Checkout` receives `student`, `partner`, `country`,
|
|
143
|
-
and `subtotal`, then selects and calculates every discount itself.
|
|
144
|
-
|
|
145
|
-
### Inventory the current owner
|
|
146
|
-
|
|
147
|
-
```text
|
|
148
|
-
Checkout knows:
|
|
149
|
-
customer flags, discount precedence, formulas, country exclusions
|
|
150
|
-
Checkout decides:
|
|
151
|
-
which discount applies
|
|
152
|
-
Checkout coordinates:
|
|
153
|
-
pricing, payment, receipt
|
|
154
|
-
Checkout changes when:
|
|
155
|
-
discount policy, payment flow, or receipt flow changes
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
The problem is not the conditional alone. Discount knowledge and behavior have
|
|
159
|
-
a different reason to change from checkout coordination.
|
|
160
|
-
|
|
161
|
-
### Write wished messages
|
|
162
|
-
|
|
163
|
-
```text
|
|
164
|
-
discount = discountPolicy.for(customer, country)
|
|
165
|
-
payable = discount.applyTo(subtotal)
|
|
166
|
-
checkout.charge(payable)
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Candidate responsibility:
|
|
170
|
-
|
|
171
|
-
```text
|
|
172
|
-
Responsibility: choose and apply the accepted discount policy
|
|
173
|
-
Knowledge: eligibility, precedence, exclusions, calculation
|
|
174
|
-
Messages: for(customer, country); applyTo(money)
|
|
175
|
-
Hidden detail: flags and formula selection
|
|
176
|
-
Creation: composition root supplies current policy set
|
|
177
|
-
Representative change: add partner eligibility and formula locally
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
If student and partner discounts share `applyTo(Money) -> Money` with the same
|
|
181
|
-
preconditions and result meaning, they may honor one role. If partner discount
|
|
182
|
-
requires an asynchronous provider lookup, it cannot silently substitute for a
|
|
183
|
-
pure discount. The boundary may instead return an eligibility decision or move
|
|
184
|
-
the lookup to the pull phase.
|
|
185
|
-
|
|
186
|
-
A local finite rule table may remain clearer than a class per discount. Add a
|
|
187
|
-
factory or registry only if creation or extension pressure is real. Constructing
|
|
188
|
-
the policy set at the edge keeps `Checkout` independent without inventing
|
|
189
|
-
discovery.
|
|
190
|
-
|
|
191
|
-
Smallest implementation surface:
|
|
192
|
-
|
|
193
|
-
```text
|
|
194
|
-
1. characterize current student behavior with responsibility-level examples
|
|
195
|
-
2. introduce DiscountPolicy behind the existing result
|
|
196
|
-
3. move one policy calculation while keeping Checkout behavior green
|
|
197
|
-
4. add partner behavior through the same caller-visible contract
|
|
198
|
-
5. inspect whether the role remains coherent; stop at the stable landing
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
This reference shapes the collaboration. The implementation protocol owns the
|
|
202
|
-
sender-by-sender mutation, and `abstraction-review` decides whether the candidate
|
|
203
|
-
is stable enough to keep.
|
|
204
|
-
|
|
205
|
-
## Sketch Output
|
|
206
|
-
|
|
207
|
-
```text
|
|
208
|
-
Change pressure: accepted change exposing the design issue
|
|
209
|
-
Current responsibility inventory: knows, decides, coordinates, creates
|
|
210
|
-
Point of attack: concrete smell on the change path
|
|
211
|
-
Wished messages: collaboration in domain language
|
|
212
|
-
Candidate ownership: data, behavior, hidden detail, reason to change
|
|
213
|
-
Variation model: role, variants, substitution and unsupported cases
|
|
214
|
-
Creation boundary: selection knowledge and factory tradeoff
|
|
215
|
-
Checks: behavior, role, integration, and pass-but-wrong cases
|
|
216
|
-
First item: smallest implementation step
|
|
217
|
-
Deferred: patterns or variants not yet supported by evidence
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
## Failure Checks
|
|
221
|
-
|
|
222
|
-
- a pattern or class hierarchy is selected before the change is stated;
|
|
223
|
-
- responsibility is inferred from duplicated syntax alone;
|
|
224
|
-
- an extracted object has no knowledge or reason to change of its own;
|
|
225
|
-
- polymorphism hides incompatible contracts;
|
|
226
|
-
- a factory solves hypothetical discovery or registration needs;
|
|
227
|
-
- dependency injection adds configuration without isolating real variation;
|
|
228
|
-
- navigation is hidden by forwarding methods without moving responsibility;
|
|
229
|
-
- tests freeze current internals rather than verify roles and behavior.
|
|
230
|
-
|
|
231
|
-
## Source Trace
|
|
232
|
-
|
|
233
|
-
- Sandi Metz, Katrina Owen, and TJ Stankus, *99 Bottles of OOP*, Second
|
|
234
|
-
Edition, version 2.2.2, 2024: chapters 3-9 on listening to change, smells and
|
|
235
|
-
points of attack, responsibility extraction, argument removal, immutability,
|
|
236
|
-
Liskov substitution, conditional-to-polymorphic movement, type transitions,
|
|
237
|
-
factories, wishful pseudocode, dependency inversion, Law of Demeter, creation
|
|
238
|
-
at the edge, and responsibility-focused testing.
|
|
239
|
-
- Harold Abelson and Gerald Jay Sussman with Julie Sussman, *Structure and
|
|
240
|
-
Interpretation of Computer Programs*, Second Edition, MIT Press, 1996:
|
|
241
|
-
multiple representations, generic operations, data-directed programming, and
|
|
242
|
-
additivity.
|
|
243
|
-
- Zachary Tellman, *Elements of Clojure*, 2019: indirection cost, module
|
|
244
|
-
assumptions, and the distinction between cohesive components and adaptable
|
|
245
|
-
interfaces.
|