passsy / favor-compositionr3
Favor Composition Over Inheritance
PublicPrefer composition over inheritance and do not write subclasses that enhance a base class, because they get complex and hard to maintain.
detector.tsisolate · reads files, writes none · no network · 100 ms · 32 MBEdit
import { mentioned, onPrompt } from "@wellactually/sdk/v3";
import { isDartProject } from "dart-kit";
/**
* Words only. Whether an `extends` is a framework requirement, an interface,
* or a subclass "enhancing" a base needs the whole hierarchy to judge; a
* line-level allowlist of blessed base classes misfires on every app-local
* base. The vocabulary is genuinely used when the topic is live.
*/
onPrompt({
*detect(event) {
if (isDartProject(event)) {
yield* mentioned(event, ["inheritance", "subclass", "subclasses", "superclass", "base class"]);
}
},
});
fixtures/dart_app/pubspec.yamlEdit
namedemo
package.jsonEdit
{
"name": "favor-composition",
"private": true,
"dependencies": {
"dart-kit": "*"
}
}