Object-oriented design principles as a lens for system architecture — SOLID, composition over inheritance, the actor model, design patterns (and when they're wrong), encapsulation, polymorphism, and responsibility-driven design. Use when evaluating code organization, module boundaries, or object/component relationships.
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "design-philosophy-object-oriented" 技能: 1. 下载 https://raw.githubusercontent.com/microsoft/amplifier-bundle-systems-design/main/skills/design-philosophy-object-oriented/SKILL.md 2. 保存为 ~/.claude/skills/design-philosophy-object-oriented/SKILL.md 3. 装好后重载技能,告诉我可以用了
OO principles as thinking tools for code organization, module boundaries, and component relationships.
Object-oriented design is not about classes and inheritance. It is about managing the cost of change by localizing decisions behind stable interfaces. Every OO principle exists to answer one question: when a requirement changes, how many places in the code must change with it?
Good OO design means a single requirement change touches one or two files. Bad OO design means shotgun surgery across a class hierarchy that was supposed to make things "extensible."
The principles below are thinking tools, not commandments. Each one has a failure mode that is just as common as the problem it solves. Know both.
SOLID is a diagnostic framework. When code is hard to change, one of these principles usually explains why. But applying them prophylactically — before you feel the pain — produces the kind of over-abstracted architecture that makes senior engineers weep.
The principle: A class should have one reason to change. "Reason to change" means one stakeholder or one axis of requirements evolution.
When it helps:
When it hurts:
The practical test: Look at your git history. If a class changes in every commit for unrelated reasons, it has too many responsibilities. If you're always changing three classes together in lockstep, they may have been split incorrectly — they share a responsibility.
The principle: Software entities should be open for extension but closed for modification. You should be able to add new behavior without editing existing, working code.
When it helps:
StripePayment, PayPalPayment without touching the payment processing core.When it hurts:
PaymentStrategy interface with a factory and a registry. You need an if statement and the willingness to refactor later.The practical test: You need OCP when you've added the third variant of something. The first is just code. The second might be an if/else. The third is when you extract the pattern. Not before.
The principle: If S is a subtype of T, then objects of type T can be replaced with objects of type S without altering the correctness of the program. Subtypes must honor the behavioral contract of their parent, not just the type signature.
When it helps:
…
Catalog of reusable architectural primitives — boundaries, contracts, state machines, queues, caches, consistency models, and more. For each: what it is, when it's right, when it's WRONG. Use when selecting patterns for a design or evaluating whether a pattern fits.
Domain-Driven Design as a lens for system architecture — bounded contexts, aggregates, ubiquitous language, context mapping, domain events, and strategic vs tactical patterns. Use when modeling complex business domains, defining service boundaries, or evaluating whether a system's structure reflects its domain.
The Unix/Linux design philosophy as a lens for system design — mechanism vs policy, composability, small tools, text streams, convention over configuration, and the principle of least surprise. Use when evaluating designs for composability, simplicity, or separation of concerns.
Domain patterns for Azure cloud architecture — compute selection, managed services, identity (Entra ID), networking, data platform, messaging, deployment, cost management, and operational patterns. Use when designing or evaluating a system deployed on Microsoft Azure.
Domain patterns for CLI tools and developer SDKs — command structure, configuration layering, plugin architecture, distribution, backward compatibility, shell integration, and failure modes. Use when designing or evaluating command-line tools, developer platforms, or SDK libraries.
Adversarial review of a system design from 6 critical perspectives -- SRE, security, staff engineer, finance, operator, and developer advocate. Produces a unified risk assessment. Use for INTERACTIVE on-demand reviews during a design conversation (/adversarial-review). For RECIPE-DRIVEN reviews (where prior step context is needed), use the systems-design-critic agent instead.