Install
openclaw skills install @dolantan548-cmd/oop-dev-skillApply universal object-oriented programming standards derived from battle-tested engineering practices. Use this skill when the user asks to review code quality, enforce coding standards, write production-grade OOP code, design class/module structure, handle exceptions, write unit tests, design database schemas, or structure multi-layer applications. Applies to any OOP language (Python, Java, C#, Go, TypeScript, Kotlin, Ruby, Swift, PHP, etc.) without language-specific lock-in.
openclaw skills install @dolantan548-cmd/oop-dev-skillThis skill encodes universal engineering standards for object-oriented software. When applied, Claude enforces these rules across any OOP language — the principles are language-agnostic unless a specific rule maps naturally to the target language's idioms.
The user may ask for code review, generation, refactoring, architecture design, test writing, or database schema design. Apply whichever sections are relevant.
_name, name_, $obj are forbidden.getUserPingfen().UpperCamelCase. Exception: well-known domain abbreviations (e.g. DTO, VO, BO) may retain their canonical form.
UserAccount, OrderService, XmlParseruserAccount, XMLparser, order_servicelowerCamelCase.
getUserById, localValue, inputUserIdMAX_RETRY_COUNT, DEFAULT_TIMEOUT_SECONDSMAX, TIMEOUTAbstract or Base.Exception (e.g. PaymentException).Test (e.g. OrderServiceTest).is. Many serialization frameworks will misread isDeleted as field deleted, causing runtime failures.
deleted, active, enabledisDeleted, isActivecondi for condition, abs for abstract — forbidden. Names must be self-explanatory.OrderFactory, LoginProxy, ResourceObserver.Translatable, Serializable, Configurable).Impl to distinguish from the interface (e.g. UserServiceImpl implements UserService).Enum; members are all-uppercase with underscores (e.g. OrderStatusEnum.PENDING_PAYMENT).| Layer | Method prefix convention |
|---|---|
| DAO/Repository | get (single), list (multiple), count, save/insert, remove/delete, update |
| Domain models | XxxDO (data object), XxxDTO (transfer), XxxVO (view), XxxBO (business) |
cache.put("Id#order_" + orderId, value)ORDER_CACHE_KEY_PREFIX = "Id#order_" as a named constant2L not 2l; 2.0f not 2.0F ambiguously).Constants class. Group into CacheConstants, SecurityConstants, ConfigConstants, etc.{} inline.=, &&, +, etc.).( or before ).if, for, while, switch) require a space before the opening parenthesis.// comment, # comment).LF).@Override in Java/Kotlin, explicit override keyword in others). This surfaces signature mismatches at compile time.0 looks like valid data; null clearly signals "not set"). Use primitives only for local variables where performance matters.init() or factory method.__repr__, toString, etc.) for easier debugging.StringBuilder, list join, etc.) — never += string in a loop body.final/const/val liberally: for classes not meant to be subclassed, for fields that must not be reassigned, for local variables that should not change.Arrays.asList() or equivalent — they are fixed-size adapters.iterator.remove().1 or -1 (never 0) violate contract and cause sort instability.capacity = (expected_count / load_factor) + 1.volatile (or equivalent) to prevent CPU/compiler reordering.switch statements: every case must either break/return or have an explicit fall-through comment. Always include a default branch, placed last.if/else/for/while/do — even single-line bodies.if-else nesting — prefer early return / guard clauses over deeply nested branches. Max 3 levels of nesting; beyond that, refactor with guard clauses, strategy pattern, or state pattern.if. Inline complex boolean expressions hurt readability.// comments.TODO/FIXME markers.TODO(author, date) — functionality not yet implemented.FIXME(author, date) — known broken code needing urgent fix.catch(Exception) except at application boundaries.finally blocks (or use language-level resource management: with, try-with-resources, using, RAII, etc.).return from a finally block — it silently swallows exceptions from the try block.isSuccess(), error code, and error message.{appName}_{logType}_{description}.log — e.g. orderservice_monitor_paymentTimeout.log.debug/trace level to avoid string interpolation cost when the level is inactive:
if logger.is_debug_enabled():
logger.debug(f"Processing order {order_id}")
Or use lazy interpolation syntax provided by the logging framework.debug in production; info selectively; warn for recoverable anomalies; error for genuine system faults only.print/console assertions — use framework assertions only.src/test/, tests/), never in the production source tree.Additional recommendations:
is_xxx, type unsigned tiny integer (0/1). All non-negative numeric fields must be unsigned.level_3_name is bad; level3_name is acceptable).user, order_item — not users).pk_ prefix for primary keys; uk_ for unique indexes; idx_ for regular indexes.DECIMAL/NUMERIC — never FLOAT/DOUBLE for stored values that require exact comparison.id (unsigned bigint, auto-increment primary key), gmt_create (datetime), gmt_modified (datetime).{business_domain}_{entity_role} (e.g. payment_task, trade_config).LIKE '%value%' defeats the index). Route full-text search to a search engine.SELECT * — always name columns explicitly.COUNT(*) is the standard row count; COUNT(col) skips NULLs. Use accordingly.IS NULL / IS NOT NULL or the equivalent function — direct equality comparison with NULL always yields NULL, not true/false.IN lists: keep under 1000 elements.gmt_modified when writing a record.Recommended layer hierarchy (each layer depends only on layers below it):
[ Open API / Gateway Layer ] [ Frontend / Template Layer ]
↓
[ Web / Controller Layer ]
↓
[ Service Layer ]
↓
[ Manager Layer ]
↓
[ DAO / Repository Layer ]
↓
[ Data Source / External APIs ]
Layer responsibilities:
Exception handling by layer:
Domain model types:
| Type | Meaning |
|---|---|
| DO / Entity | Maps 1:1 to a DB table row |
| DTO | Data transferred between service boundaries |
| BO | Encapsulates business logic output |
| VO | Data shaped for the view/UI layer |
| Query object | Encapsulates query parameters (2+ params → object, not map) |
MAJOR.MINOR.PATCH — start at 1.0.0. Major = breaking change; Minor = backward-compatible features; Patch = bug fixes.groupId + artifactId with different versions within the same build graph.