{"id":"template-method-inheritance-bounded-by-composition","text":"Template Method's principled inheritance counterexample and Decorator's demonstrated composition scalability together illuminate two key regions of the reuse decision space: Template Method identifies specific structural constraints under which inheritance-based reuse can be disciplined (algorithm skeletons with fine-grained override control), while Decorator's exponential advantage over inheritance in feature combination illustrates why composition tends to be the stronger default — offering practitioners both a qualified exception and a concrete basis for the general preference.","truth_value":"IN","source":"","source_url":"","source_hash":"","justifications":[{"type":"SL","antecedents":["template-method-principled-inheritance-counterexample","decorator-proves-composition-scalability"],"outlist":[],"label":"Template Method defines when inheritance works; Decorator proves composition works everywhere else"}],"dependents":["composition-paradigm-convergent-and-scalable-with-bounded-exception"],"metadata":{"source_type":"derived","review_result":"pass","repair_action":"softened"},"created_at":"2026-06-17T23:41:07+00:00","updated_at":"2026-06-18T06:15:08+00:00","reviewed_at":"2026-06-18T06:15:08+00:00","verified_at":"","retracted_at":"","explanation":{"steps":[{"node":"template-method-inheritance-bounded-by-composition","truth_value":"IN","reason":"SL justification valid","antecedents":["template-method-principled-inheritance-counterexample","decorator-proves-composition-scalability"],"label":"Template Method defines when inheritance works; Decorator proves composition works everywhere else"},{"node":"template-method-principled-inheritance-counterexample","truth_value":"IN","reason":"SL justification valid","antecedents":["template-method-fine-grained-override-control","composition-superiority-for-reuse"],"label":"Template Method is the exception that proves the composition rule by showing when inheritance works"},{"node":"template-method-fine-grained-override-control","truth_value":"IN","reason":"SL justification valid","antecedents":["gof-template-method-five-operation-kinds","hook-operations-overridable-defaults","gof-cpp-template-method-nonvirtual"],"label":"Five operation kinds plus non-virtual skeleton produce the most controlled inheritance in the GoF"},{"node":"gof-template-method-five-operation-kinds","truth_value":"IN","reason":"premise"},{"node":"hook-operations-overridable-defaults","truth_value":"IN","reason":"premise"},{"node":"gof-cpp-template-method-nonvirtual","truth_value":"IN","reason":"premise"},{"node":"composition-superiority-for-reuse","truth_value":"IN","reason":"SL justification valid","antecedents":["favor-composition-over-inheritance","inheritance-breaks-encapsulation","inheritance-compile-time-composition-run-time","delegation-composition-as-powerful-as-inheritance"],"label":"Four independent arguments converge on composition's superiority over inheritance"},{"node":"favor-composition-over-inheritance","truth_value":"IN","reason":"premise"},{"node":"inheritance-breaks-encapsulation","truth_value":"IN","reason":"premise"},{"node":"inheritance-compile-time-composition-run-time","truth_value":"IN","reason":"premise"},{"node":"delegation-composition-as-powerful-as-inheritance","truth_value":"IN","reason":"premise"},{"node":"decorator-proves-composition-scalability","truth_value":"IN","reason":"SL justification valid","antecedents":["decorator-avoids-inheritance-explosion","composition-superiority-for-reuse"],"label":"Decorator's avoidance of class explosion quantifies composition's advantage as exponential, not just qualitative"},{"node":"decorator-avoids-inheritance-explosion","truth_value":"IN","reason":"premise"}]}}