agentleFS
cookieMonsterDevcookieMonsterDev/agents-skills/skills/architecture/object-oriented-programming-paradigm/SKILL.md

object-oriented-programming-paradigm

Skill7 starsChanged 15 days agoMITView on GitHub

Object-oriented programming concepts (classes, the four pillars, object relationships, SOLID, coupling and cohesion, Law of Demeter), with a reference and runnable examples per concept. Use when a question names an OOP concept or SOLID principle, models a domain with classes and interfaces, compares concepts, or asks to review or refactor class designs.

The file

Files
SKILL.md

Object-Oriented Programming Paradigm

Ground every OOP answer in this skill's reference files, not in improvised definitions. Reuse behavior through composition and interfaces; reserve inheritance for true subtype specialization.

Workflow

For class-design reviews or refactoring, first read review and refactoring for caller-based evidence, invariant checks, and migration boundaries.

  1. Identify the concept(s) in the catalog below, by name or by symptom: a subclass that breaks where its base is expected, a god class, a deep hierarchy, a leaky abstraction, a train-wreck call chain. Done when every concept the question names or implies is listed, or when the problem is better served by plain functions and data; then answer with those.
  2. Read each identified reference at references/<concept>.md in full. When comparing concepts, read every one compared and contrast their intent, not their structure.
  3. Read the language example at examples/<concept>/<concept>.<ext> for the user's language. For C, Go, Rust, or another language without an example, use the reference's Language Notes for the idiomatic mapping.
  4. Answer with what the concept means, when it applies, the simpler alternative and when it wins, and code adapted to the user's domain. Write the language's idiomatic form rather than a textbook Java-style class diagram: protocols and duck typing in Python, structs and protocols in Swift, closures where a one-method class would be ceremony. When reviewing code, name the violated principle and show the minimal refactor of the user's code. Done when every identified concept has all four parts.

Concept Catalog

Building Blocks

The vocabulary of object-oriented code: what classes, objects, and contracts are.

ConceptIntentReference
Classes & ObjectsBundle state and behavior into a blueprint; instantiate independent objects from itreferences/classes-and-objects.md
Interfaces & Abstract ClassesSeparate a contract from its implementations; share partial implementation safelyreferences/interfaces-and-abstract-classes.md

The Four Pillars

The defining properties of the paradigm.

ConceptIntentReference
EncapsulationHide internal state behind a controlled interface that preserves invariantsreferences/encapsulation.md
AbstractionExpose a component's essential model while hiding operational detailreferences/abstraction.md
InheritanceDerive specialized classes from a base, reusing and extending its behaviorreferences/inheritance.md
PolymorphismLet one call site work across many concrete types (subtype, parametric, ad hoc)references/polymorphism.md

Object Relationships

How objects reference, own, and assemble each other.

ConceptIntentReference
Object RelationshipsDistinguish association, aggregation, and composition by ownership and lifetimereferences/object-relationships.md
Composition over InheritanceBuild behavior by assembling parts instead of extending deep hierarchiesreferences/composition-over-inheritance.md

SOLID Principles

Five principles for class design that keep change local.

PrincipleIntentReference
Single ResponsibilityGive each class one reason to changereferences/single-responsibility.md
Open/ClosedMake code open for extension without modifying what already worksreferences/open-closed.md
Liskov SubstitutionEnsure subtypes are usable anywhere their base type is expectedreferences/liskov-substitution.md
Interface SegregationPrefer many small client-specific interfaces over one fat interfacereferences/interface-segregation.md
Dependency InversionMake high-level policy depend on abstractions, not concrete implementationsreferences/dependency-inversion.md

Design Qualities

Cross-cutting qualities used to judge an object-oriented design.

ConceptIntentReference
Coupling & CohesionMinimize dependence between modules and maximize relatedness within themreferences/coupling-and-cohesion.md
Law of DemeterTalk only to immediate collaborators instead of reaching through object graphsreferences/law-of-demeter.md

Examples

Examples are self-contained and runnable, in the languages with first-class classes: Python, C++, Java, C#, JavaScript, PHP, and Swift.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.