oop-best-practices
Skill5 starsChanged 30 days agoMITView on GitHub
Use when designing or reviewing object responsibilities, naming, encapsulation, value-object equality, immutability, parsing or normalization, collections, cohesion, dependency direction, Tell Don't Ask, Law of Demeter, Object Calisthenics, SOLID, or composition versus inheritance. Focuses on everyday object design; use DDD for context boundaries and pattern guidance for named pattern selection.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- sviatil0/claude-skillstheir own version, first seen Jul 14, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- sviatil0/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- boostSkill
- data-migration-best-practicesSkill
- ddd-best-practicesSkill
- design-patterns-best-practicesSkill
- flowSkill
- fp-best-practicesSkill
- infrastructure-designSkill
- refactoring-best-practicesSkill
- rest-api-best-practicesSkill
- tdd-best-practicesSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
44 rules. About 0 are common, 21 are distinctive, and 23 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈21
Distinctive · estimate
This author's own choices. Worth a look.
23
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Use this skill for everyday coding decisions that shape readability, cohesion, and long-term maintainability.
- Distinctive: line 14
Use it especially when the task benefits from:
- Distinctive: line 23
Write code for the next reader, not just for the compiler.
- Distinctive: line 24
Keep behavior close to the concept that owns it.
- Distinctive: line 25
Prefer simple collaborations over clever object graphs.
- Distinctive: line 26
Use names, boundaries, and APIs to reveal intent.
- Distinctive: line 56
If a name is weak, question the abstraction before polishing the wording.
- Distinctive: line 57
Avoid premature abstractions that erase the concept or guess too much future reuse.
- Distinctive: line 58
Remove duplicated knowledge, not merely duplicated syntax.
- Distinctive: line 63
Prefer rich objects over data carriers when the concept has meaningful behavior.
- Distinctive: line 68
Prefer asking collaborators for meaningful behavior over pulling data out.
- Distinctive: line 70
Keep public interfaces small, explicit, and intention revealing.
- Distinctive: line 74
Prefer composition when behavior changes independently.
- Distinctive: line 75
Keep inheritance shallow and honest.
- Distinctive: line 76
Avoid object graphs that force train-wreck navigation.
- Distinctive: line 80
Prefer intention-revealing names over short names.
- Distinctive: line 81
Keep methods shallow and centered on one level of abstraction.
- Distinctive: line 82
Use early returns when they reduce branching noise.
- Distinctive: line 83
Keep classes cohesive instead of merely small.
- Distinctive: line 85
Prefer telling collaborators what to do over asking for their data and deciding elsewhere.
- Distinctive: line 90
Keep public APIs smaller than internal implementation detail.
- Very specific: line 110
Read references/interface-depth.md when assessing interface complexity, pass-through layers, or the state a caller must track.
- Very specific: line 112
Read references/core-principles.md for condensed coding heuristics.
- Very specific: line 113
Read references/book-influences.md for a source-oriented map of the key books behind this skill.
- Very specific: line 114
Read references/naming-and-abstractions.md when naming or abstraction quality is the main issue.
- Very specific: line 115
Read references/message-based-design.md when object collaboration and roles matter most.
- Very specific: line 116
Read references/advanced-modeling-concepts.md for richer object choices that still stay within everyday OO design.
- Very specific: line 117
Read references/fran-iglesias-practical-guidance.md for practical OO heuristics distilled from Fran Iglesias.
- Very specific: line 118
Read references/solid-principles.md when SOLID violations or design pressure around single responsibility, open-closed, or dependency …
- Very specific: line 119
Read references/object-calisthenics.md when applying strict OO discipline rules to clean up a class or method.
- Very specific: line 120
Read references/dependency-management.md when coupling, dependency direction, or collaborator injection decisions are the focus.
- Very specific: line 121
Read references/method-design.md when method length, abstraction level, or intention-revealing structure is the problem.
- Very specific: line 122
Read references/gradual-abstraction.md when the right moment to introduce abstraction is unclear or the design is being over-engineered too …
- Very specific: line 123
Read references/language-examples.md for an index of language-specific example files (TypeScript, Java, Python, C#, Ruby, PHP, Go, Rust).
- Very specific: line 124
Read references/go-examples.md for OOP concepts in Go (structs, implicit interfaces, composition, no inheritance).
- Very specific: line 125
Read references/rust-examples.md for OOP concepts in Rust (structs, traits, newtype pattern, ownership as immutability).
- Very specific: line 126
Read references/simple-design-rules.md for Kent Beck's 4 Rules of Simple Design: passes tests, reveals intention, no duplication, fewest …
- Very specific: line 127
Read references/oop-good-practices-examples.md for corrected cross-language lessons on Demeter, Tell Don't Ask, named construction, …
- Very specific: line 128
Read references/value-objects-advanced.md as the canonical Value Object guide: selection criteria, invariant ownership, …
- Very specific: line 132
Use ddd-best-practices when object ownership also defines a consistency, lifecycle, repository, or transaction boundary.
- Very specific: line 133
Use tdd-best-practices for Value Object contract tests, boundary analysis, property-based tests, and deterministic fixtures.
- Very specific: line 134
Use refactoring-best-practices for risky or legacy code changes.
- Very specific: line 135
Use design-patterns-best-practices when the main question is pattern selection.
- Very specific: line 136
Use rest-api-best-practices when designing the HTTP API surface that exposes these objects.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
OOP Best Practices
Use this skill for everyday coding decisions that shape readability, cohesion, and long-term maintainability.
Use it especially when the task benefits from:
- stronger naming and more explicit abstractions
- clearer object responsibilities and encapsulated invariants
- message-based collaboration and role-oriented objects
- composition over inheritance in everyday design choices
Working Style
- Write code for the next reader, not just for the compiler.
- Keep behavior close to the concept that owns it.
- Prefer simple collaborations over clever object graphs.
- Use names, boundaries, and APIs to reveal intent.
- Let objects carry their own rules when they can.
Review Workflow
- Identify the concept.
- What concept is this code modeling?
- What rules or invariants belong to that concept?
- Check the boundary.
- Is the object exposing raw data or meaningful behavior?
- Are callers forced to know too much about internal structure?
- Check the shape.
- Are methods mixing multiple abstraction levels?
- Is the class carrying more than one reason to change?
- Are names explicit enough to understand intent quickly?
- Apply the lightest useful improvement.
- rename for clarity
- extract method
- extract value object
- extract first-class collection
- move behavior to the object that owns the data
- split the class by responsibility
Additional Review Lenses
Naming and abstraction discipline
- If a name is weak, question the abstraction before polishing the wording.
- Avoid premature abstractions that erase the concept or guess too much future reuse.
- Remove duplicated knowledge, not merely duplicated syntax.
Encapsulation and object responsibility
- Move rules to the concept that owns them.
- Prefer rich objects over data carriers when the concept has meaningful behavior.
- Let services orchestrate when objects can own the rule.
Message-based design
- Prefer asking collaborators for meaningful behavior over pulling data out.
- Depend on roles and messages rather than concrete internal structure.
- Keep public interfaces small, explicit, and intention revealing.
Structural simplicity
- Prefer composition when behavior changes independently.
- Keep inheritance shallow and honest.
- Avoid object graphs that force train-wreck navigation.
Day-to-Day Rules
- Prefer intention-revealing names over short names.
- Keep methods shallow and centered on one level of abstraction.
- Use early returns when they reduce branching noise.
- Keep classes cohesive instead of merely small.
- Introduce a Value Object when identity does not matter and semantic guarantees, type safety, or behavior justify a domain type.
- Prefer telling collaborators what to do over asking for their data and deciding elsewhere.
- Introduce first-class collections when collections have their own invariants.
- Give Value Objects semantic equality, matching hash behavior, and deeply immutable observation; do not rely on object-reference equality or shallow
readonly. - Depend on small roles instead of volatile concrete details.
- Prefer composition when behavior changes independently.
- Keep public APIs smaller than internal implementation detail.
Good Signals
- The class name matches the behavior it owns.
- Invalid states are rejected early.
- Most methods can be understood without reading unrelated helpers.
- Callers depend on a small surface area.
- The same concept is named consistently across the codebase.
Warning Signs
- A method needs several comments to be readable.
- A class mostly exposes getters and setters.
- Many callers repeat the same validation or branching logic.
- A change in one concept forces edits across many unrelated files.
- The object model looks like data transport with behavior bolted on elsewhere.
References
- Read
references/interface-depth.mdwhen assessing interface complexity, pass-through layers, or the state a caller must track. - Read
references/core-principles.mdfor condensed coding heuristics. - Read
references/book-influences.mdfor a source-oriented map of the key books behind this skill. - Read
references/naming-and-abstractions.mdwhen naming or abstraction quality is the main issue. - Read
references/message-based-design.mdwhen object collaboration and roles matter most. - Read
references/advanced-modeling-concepts.mdfor richer object choices that still stay within everyday OO design. - Read
references/fran-iglesias-practical-guidance.mdfor practical OO heuristics distilled from Fran Iglesias. - Read
references/solid-principles.mdwhen SOLID violations or design pressure around single responsibility, open-closed, or dependency inversion are the main issue. - Read
references/object-calisthenics.mdwhen applying strict OO discipline rules to clean up a class or method. - Read
references/dependency-management.mdwhen coupling, dependency direction, or collaborator injection decisions are the focus. - Read
references/method-design.mdwhen method length, abstraction level, or intention-revealing structure is the problem. - Read
references/gradual-abstraction.mdwhen the right moment to introduce abstraction is unclear or the design is being over-engineered too early. - Read
references/language-examples.mdfor an index of language-specific example files (TypeScript, Java, Python, C#, Ruby, PHP, Go, Rust). - Read
references/go-examples.mdfor OOP concepts in Go (structs, implicit interfaces, composition, no inheritance). - Read
references/rust-examples.mdfor OOP concepts in Rust (structs, traits, newtype pattern, ownership as immutability). - Read
references/simple-design-rules.mdfor Kent Beck's 4 Rules of Simple Design: passes tests, reveals intention, no duplication, fewest elements — with CodelyTV examples. - Read
references/oop-good-practices-examples.mdfor corrected cross-language lessons on Demeter, Tell Don't Ask, named construction, collection identity, dependency roles, and course counterexamples. - Read
references/value-objects-advanced.mdas the canonical Value Object guide: selection criteria, invariant ownership, construction/parsing, equality and hashing, deep immutability, behavior, optionality, first-class collections, persistence, testing, and safe evolution.
Related Skills
- Use
ddd-best-practiceswhen object ownership also defines a consistency, lifecycle, repository, or transaction boundary. - Use
tdd-best-practicesfor Value Object contract tests, boundary analysis, property-based tests, and deterministic fixtures. - Use
refactoring-best-practicesfor risky or legacy code changes. - Use
design-patterns-best-practiceswhen the main question is pattern selection. - Use
rest-api-best-practiceswhen designing the HTTP API surface that exposes these objects.
Source Influences
This skill is synthesized from ideas emphasized in:
Sustainable Codeby Carlos BléImplementation Patternsby Kent BeckPractical Object-Oriented Design in Rubyby Sandi Metz99 Bottles of OOPby Sandi Metz- Fran Iglesias's
design-principlesarticles - Fran Iglesias's
good-practicesarticles - Fran Iglesias's
Object Calisthenicsseries - CodelyTV OOP Good Practices course (including progressive and overwritten educational counterexamples)
- CodelyTV Aggregates course
- CodelyTV Value Objects course
- CodelyTV Four Rules of Simple Design course (including intentional naming, YAGNI, interface, duplication, and testing counterexamples)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

