Token导航 LogoToken导航TokenDH.com
研究检索external-serviceclawhub未标认证来源可访问clear审计通过

bookforge-domain-logic-pattern-selectorbookforge 域逻辑模式选择器

Agent Skill

bookforge-domain-logic-pattern-selector 用于查找、检索和筛选相关信息,适合在 OpenClaw 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,011

周安装

123

GitHub Stars

公开资料未说明

下载量

974
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:bookforge-domain-logic-pattern-selector(bookforge 域逻辑模式选择器)
来源仓库:https://github.com/quochungto/bookforge-domain-logic-pattern-selector
安装命令:
openclaw skills install bookforge-domain-logic-pattern-selector
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install bookforge-domain-logic-pattern-selector

简介

为子系统选择事务脚本、领域模型等逻辑组织模式。

  • 适用于企业应用架构设计与演进规划场景。
  • 根据业务复杂度决定服务层厚度和聚合根设计。
  • 需评估团队对 DDD 的理解程度再决定是否采用领域模型。
  • 输出包含模式对比表和迁移路径说明。bookforge-domain-logic-pattern-selector 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

name
domain-logic-pattern-selector
description
Choose domain logic pattern for enterprise application subsystems: Transaction Script vs Domain Model vs Table Module, and decide Service Layer thickness. Use when organizing business logic, choosing between procedural service methods and rich domain models, selecting enterprise app architecture, routing domain logic to the right pattern, deciding anemic domain model vs rich domain model, applying Fowler's complexity-vs-effort curve, determining when to use Domain Model, when to use Transaction Script for simple CRUD, when Table Module fits .NET RecordSet environments, deciding Service Layer facade vs operation script vs controller-entity, avoiding transaction-script-sprawl, avoiding anemic-domain-model anti-pattern, preventing stored-procedure logic leakage, structuring enterprise app business logic, domain logic organization, choose domain pattern, enterprise app business logic design.
version
1.0.0
homepage
https://github.com/bookforge-ai/bookforge-skills/tree/main/books/patterns-of-enterprise-application-architecture/skills/domain-logic-pattern-selector
metadata
{"openclaw":{"emoji":"🗂️","homepage":"https://github.com/bookforge-ai/bookforge-skills"}}
status
draft
source-books
title
Patterns of Enterprise Application Architecture
authors
["Martin Fowler", "David Rice", "Matthew Foemmel", "Edward Hieatt", "Robert Mee", "Randy Stafford"]
chapters
[2, 9]
domain
software-architecture
tags
depends-on
[]
execution
tier
2
mode
hybrid
inputs
description
Subsystem description: what the module does, the nature of the business rules (simple CRUD, rule-heavy, algorithmic), team OO experience, language and stack (Java, C#, Python, .NET, JVM), any existing patterns in place, and whether multiple client types or transactional resources are involved.
description
Optional: existing domain and service code to diagnose current pattern and detect anti-patterns.
tools-required
tools-optional
mcps-required
[]
environment
Enterprise application codebase or architecture discussion. Works offline. Codebase helpful but not required — skill operates on description alone.
discovery
goal
Route a subsystem to Transaction Script, Domain Model, or Table Module, decide Service Layer thickness, and produce a domain-logic pattern decision record.
tasks
audience
roles
experience
intermediate
when_to_use
triggers
prerequisites
[]
not_for
environment
codebase_required
false
codebase_helpful
true
works_offline
true
quality
scores
with_skill
null
baseline
null
delta
null
tested_at
null
eval_count
null
assertion_count
13
iterations_needed
null

Domain Logic Pattern Selector

Choose between Transaction Script, Domain Model, and Table Module for a subsystem, then decide how thick to make the Service Layer. Based on Fowler's Patterns of Enterprise Application Architecture (Ch 2 + Ch 9).

When to Use

Use this skill when starting or refactoring a subsystem and the central question is: _how should business logic be organized?_ This is distinct from _where_ that logic persists (data-source patterns) or _how_ it is presented.

Typical triggers: greenfield module design, Transaction Script code growing unmanageable, a team debate about "should we use DDD?", evaluating whether to add a service layer, diagnosing anemic domain model or script sprawl in legacy code.

Prerequisites: none. Works from a verbal description of the subsystem; codebase access improves diagnosis.

Context & Input Gathering

Ask the user (or read from codebase) in this order:

Required:

  1. What does the subsystem do? One paragraph — the nouns (entities), the operations (use cases), and the outputs.
  2. How complex is the business logic? Pick the best match:

- Simple: mostly CRUD, a few validations, no conditional algorithms - Moderate: validations + multi-step calculations + some conditional rules - Complex: many rules that interact, vary by product/customer/time, change frequently

  1. What is the team's OO experience? Low (procedural background), moderate (OO-familiar but not DDD-trained), high (experienced with rich domain models, strategy/composite patterns).
  2. What is the language and stack? Java/JVM, C#/.NET, Python, TypeScript, Ruby, etc. If .NET, is ADO.NET / RecordSet usage widespread?

Observable from codebase (if provided):

  • Service classes with many long methods containing if/else chains → Transaction Script
  • Classes with fields but no methods (getters/setters only) → anemic domain model signal
  • Behavior scattered across utility/helper classes → Transaction Script sprawl
  • SQL or stored-procedure calls embedded directly in business-logic code → stored-procedure leakage
  • Dataset/DataTable types flowing through business logic (.NET) → Table Module context

Defaults if not specified:

  • Team OO experience: moderate
  • Stack: JVM (Java/Kotlin) unless .NET signals are present

Sufficiency test: Proceed once complexity level and team experience are known. Stack is tie-breaker for moderate complexity.

Process

Step 1 — Classify Domain Complexity

WHY: Fowler's core insight is that the cost curves for the three patterns cross at different complexity points. Choosing the wrong pattern for the complexity level locks the team into a wall of effort as logic grows.

Map the subsystem to one of three complexity bands:

BandSignalsCost Curve Behavior
LowPure CRUD, few validations, minimal branchingAll three patterns are cheap. Transaction Script wins on simplicity.
ModerateMulti-step calculations, conditional rules, some shared logicTransaction Script starts showing duplication. Domain Model pays off if team is OO-comfortable. Table Module is viable if RecordSet tooling is strong.
HighRules vary by product/customer/time, complex invariants, frequent changes, algorithmic variationTransaction Script hits exponential complexity wall. Domain Model is the only pattern that manages growth gracefully.

If the codebase is available: grep for service methods longer than ~50 lines with nested conditionals. That is a high-complexity signal even if the requirement description sounds simple.

Step 2 — Apply the Routing Matrix

WHY: Complexity alone does not determine the best pattern. Team OO experience shifts the cost curve for Domain Model (familiar teams pay the ramp-up cost once; unfamiliar teams pay it every sprint). Platform shifts the appeal of Table Module (RecordSet tooling makes it a natural fit in .NET; without that tooling it is pointless friction).

ROUTING MATRIX
─────────────────────────────────────────────────────────────────────
Complexity   Team OO Exp    Platform         → Recommended Pattern
─────────────────────────────────────────────────────────────────────
Low          any            any              → Transaction Script
Moderate     low            any              → Transaction Script (with extraction discipline)
Moderate     moderate/high  .NET + RecordSet → Table Module
Moderate     moderate/high  Java/Python/TS   → Domain Model (simple variant)
High         low            any              → Domain Model + coaching (or Table Module in .NET as interim)
High         moderate/high  any              → Domain Model
─────────────────────────────────────────────────────────────────────

Platform defaults (Fowler's explicit guidance):

  • .NET with ADO.NET / DataSet: Table Module is the natural fit. Fowler says "I don't see a reason to use Transaction Script in a .NET environment" once RecordSet tooling is present.
  • Java / JVM: Domain Model is the natural target for moderate-to-high complexity. POJOs (plain old Java objects) with Data Mapper is the recommended implementation — avoid entity beans for rich domain models.
  • Python / Ruby / TypeScript: Domain Model with Active Record is viable for simple-to-moderate domains; Data Mapper for rich ones.

Refactoring direction rule: If starting fresh or refactoring up — Transaction Script → Domain Model is a well-worn path. Going the other direction (Domain Model → Transaction Script) is rarely worthwhile unless you can also simplify the data-source layer. Start simple; refactor up when complexity demands.

Mixed patterns are allowed. Transaction Script for some use cases, Domain Model for the core rules — Fowler explicitly calls this common.

Step 3 — Decide Service Layer

WHY: A Service Layer defines the application boundary — where transaction control and security live, and what coarse-grained API client layers (UI, APIs, messaging consumers) call into. Adding it unnecessarily layers overhead; omitting it when multiple client types exist causes cross-cutting logic to scatter.

Add a Service Layer when ANY of these are true:

  • More than one kind of client (UI + REST API, UI + message consumer, UI + batch job)
  • A use case response must be transacted atomically across multiple resources (database + message queue + email)
  • Need a distinct, stable API boundary (versioning, remote access, access control)

Skip the Service Layer when:

  • Single client type (a UI), simple use cases, single transactional resource
  • Page Controllers can control transactions directly by delegating to the domain or data-source layer

Thickness — three variants:

VariantDescriptionWhen to UseFowler's Verdict
Domain Facade (thin)Service layer methods are one-liner delegations to the Domain Model. No business logic here.When Domain Model is rich and self-contained.Preferred by Fowler when using Domain Model.
Operation Script (thick)Service methods contain application logic (notifications, workflow coordination, cross-resource transactions), delegating domain logic to domain objects.When application logic (workflow, integration, notifications) must be coordinated.Fowler's pick for applications with application-logic responsibilities.
Controller-Entity (mid)Use-case-specific logic in service/controller scripts; shared logic on entities.Common but risky — tend to produce duplication.Fowler warns against this as a starting point; useful only when refactoring from Transaction Script.

Avoid stored procedures for domain logic. Reserve stored procedures for batch jobs and extreme performance requirements only. Placing business rules in stored procedures creates logic you cannot test, version, or refactor as a domain model.

Step 4 — Check Anti-Pattern Risk

WHY: Pattern choices create pressure toward specific failure modes. Flagging the risk up front lets the team establish guards before the anti-pattern takes hold.

Chosen PatternPrimary Anti-Pattern RiskEarly Warning SignsGuard
Transaction ScriptTransaction Script Sprawl: logic duplicated across scripts; one god-class serviceMethods >50 lines; copy-pasted validation blocks; service class >500 linesExtract shared logic into domain objects; set line-count budget
Domain ModelAnemic Domain Model: classes with only getters/setters; all behavior in service layerDomain class has zero methods beyond accessors; service layer orchestrates every operationMove behavior onto entities; services handle only application logic
Domain ModelBloated Domain Model: domain objects absorbing use-case-specific UI behaviorDomain class imports UI or HTTP typesMove use-case-specific logic to service layer or presentation; keep domain pure
Table ModuleStored-Procedure Logic Leakage: rules drift into the databaseBusiness conditionals in SQL; procedures called from Table ModuleKeep calculation logic in Table Module C# / VB class, not in SQL

Anemic Domain Model is Fowler's most prominent warning: a system that uses Domain Model classes but has stripped behavior out into service classes reduces the pattern to an expensive object-relational mapping exercise with none of the encapsulation benefit. If your "domain model" has no methods beyond getters and setters, it is a data transfer layer, not a domain model.

Step 5 — Produce the Decision Record

WHY: A written record anchors the decision, gives future maintainers the context to maintain pattern consistency, and becomes a checklist for code review.

Produce a Domain-Logic Pattern Decision Record containing:

## Domain-Logic Pattern Decision Record: [Subsystem Name]

### Classification
- Complexity band: [low / moderate / high]
- Team OO experience: [low / moderate / high]
- Stack / platform: [Java / .NET / Python / ...]

### Primary Pattern: [Transaction Script | Domain Model | Table Module]
**Rationale:** [1-2 sentences applying the routing matrix]

### Service Layer: [None | Domain Facade | Operation Script | Controller-Entity]
**Rationale:** [Why needed / not needed; thickness reasoning]

### Anti-Pattern Watch
- Risk: [name]  Warning sign: [observable symptom]

### Migration Path (if refactoring)
[Starting point → recommended direction → end state]

### Implementation Sketch
[5-10 lines of pseudocode or language-idiomatic code showing the structural skeleton]

### Pair With Data-Source Pattern
[Brief note on which data-source pattern pairs with the chosen domain pattern]

Inputs

InputRequiredDescription
Subsystem descriptionYesWhat it does, the entities, the use cases
Complexity levelYesLow / moderate / high (or description to classify)
Team OO experienceYesLow / moderate / high
Language / stackYes (for tie-breaking)JVM, .NET, Python, etc.
Existing codebaseNoHelps diagnose current pattern and anti-patterns
Multiple client types?NoDefaults to single client (no Service Layer)

Outputs

  • Domain-Logic Pattern Decision Record (markdown) — primary output
  • Routing rationale — explicit complexity × team × platform reasoning
  • Anti-pattern risk flags — with early warning signs and guards
  • Implementation skeleton — language-idiomatic structural sketch
  • Service Layer decision — thickness recommendation with rationale
  • Data-source pairing note — which data-source pattern to combine with the chosen domain pattern

Key Principles

  1. Complexity determines the crossover point, not personal preference. Fowler's complexity-vs-effort graph shows that Domain Model costs more upfront but grows sub-linearly while Transaction Script cost grows super-linearly. The crossover is real but cannot be measured precisely — use experienced judgment on domain complexity signals.
  1. Team experience shifts the curve but does not override complexity. A team unfamiliar with OO domain models lowers the break-even point (they pay ramp-up cost longer), but high-complexity domains still demand Domain Model eventually. The alternative is unbounded Transaction Script sprawl.
  1. Platform preference is Fowler's explicit tie-breaker. .NET RecordSet tooling makes Table Module the natural mid-complexity choice. Without that tooling, Table Module adds no value over a simple Domain Model with Active Record.
  1. Refactor up, rarely down. If you start with Transaction Script and complexity grows: refactor toward Domain Model. If you start with Domain Model and want simplicity: going back to Transaction Script is rarely worth it unless you simultaneously simplify the data-source layer.
  1. The anemic domain model is a pattern failure, not a design choice. Stripping behavior from domain classes into services defeats the purpose of Domain Model. If your domain classes have no methods, you are paying ORM complexity without the encapsulation benefit.
  1. Service Layer thickness should match application-logic responsibility. Thin facade when the Domain Model carries all logic. Operation script when use cases require coordinating notifications, messaging, and multi-resource transactions. Avoid controller-entity as an architectural style — it tends to replicate Transaction Script duplication inside the service layer.
  1. Mixed patterns are legitimate. Simple subsystems within a Domain Model application can use Transaction Script. The patterns are not mutually exclusive — the key is conscious, documented choice.

Examples

Scenario A — Revenue Recognition Engine (Complex Rules → Domain Model)

Trigger: A team building a SaaS billing system. Revenue recognition rules vary by product type: word processors recognize 100% immediately; spreadsheets spread recognition over three dates; databases over two; and the CFO adds new product categories quarterly.

Process:

  • Classify: High complexity — rules vary by product, change frequently, involve calculations and date logic.
  • Route: Domain Model (complexity high → Domain Model regardless of team experience).
  • Service Layer: Operation Script — use case requires updating the database and notifying contract administrators atomically.
  • Anti-pattern check: Risk of anemic domain model if the recognition strategy is placed in the service layer. Guard: RevenueRecognition objects should carry the isRecognizableBy(date) method; strategy subclasses should carry calculateRevenueRecognitions(). The service layer only coordinates the transaction and sends notifications.

Output: Domain Model with Contract, Product, RevenueRecognition, and a strategy hierarchy (CompleteRecognitionStrategy, ThreeWayRecognitionStrategy). RecognitionService is an Operation Script service layer that delegates domain logic to domain objects and handles email/integration notifications.


Scenario B — Simple Order Management (.NET CRUD → Table Module)

Trigger: A .NET team building internal order management. Rules are mostly: validate fields, calculate totals, apply standard discounts. All UI is data-grid based. ADO.NET DataSets flow through every layer.

Process:

  • Classify: Low-to-moderate complexity. No complex invariants, no algorithmic variation.
  • Route: Table Module. .NET RecordSet tooling is present; the calculation logic fits naturally in table-oriented classes.
  • Service Layer: None needed — single client (a Windows Forms UI), single transactional resource.
  • Anti-pattern check: Watch for stored-procedure logic drift. Keep discount calculation in the Order Table Module, not in a SQL stored procedure.

Output: Contract Table Module, Product Table Module, RevenueRecognition Table Module operating on a shared DataSet. No domain object identity — every operation takes a primary key parameter.


Scenario C — Legacy Transaction Scripts Hitting Complexity Wall → Refactor to Domain Model

Trigger: A Java team's billing service has grown to a 2,000-line BillingService class. Discount logic is copy-pasted across five methods. Adding a new rule requires touching seven places.

Process:

  • Classify: Transaction Script sprawl — the complexity has exceeded the pattern's capacity.
  • Route: Refactor toward Domain Model. Direction: up, not down.
  • Service Layer: Keep BillingService as an Operation Script service layer; move business rules onto Contract, LineItem, and Discount domain objects.
  • Migration path: Extract duplicate validation into domain object methods first; introduce Data Mapper to decouple persistence; migrate rule-specific conditional branches into strategy classes.
  • Anti-pattern check: Do not introduce an anemic domain model by moving methods from BillingService to new classes that only hold data. Behavior must move too.

Output: Decision record documenting the refactor direction, a domain object skeleton (Contract, LineItem, Discount), BillingService reduced to coordinating transactions and notifications, and a Data Mapper recommendation for persistence.

References

  • references/complexity-vs-effort-graph.md — Fowler's unquantified-but-instructive chart described textually with decision thresholds
  • references/revenue-recognition-four-ways.md — the three-table schema (products / contracts / revenueRecognitions) implemented as Transaction Script (Java), Domain Model (Java), Table Module (C#), and Service Layer (Java)
  • references/service-layer-thickness-guide.md — detailed comparison of domain facade, operation script, and controller-entity with code sketches

If unclear which data-source pattern to pair with the chosen domain pattern → invoke data-source-pattern-selector. If unclear whether a distribution boundary (Remote Facade, DTO) is needed → invoke distribution-boundary-designer. If unsure which overall layering approach fits the application → invoke enterprise-architecture-pattern-stack-selector.

License

This skill is licensed under CC-BY-SA-4.0. Source: BookForge — Patterns of Enterprise Application Architecture by Martin Fowler et al. (Addison-Wesley, 2002).

Related BookForge Skills

This skill is standalone. Browse more BookForge skills: bookforge-skills

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

97.78%
按下载量换算952

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills