Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

Implements comprehensive documentation for Business Logic Patterns section covering Transaction Script, Domain Model, and Service Layer patterns with working TypeScript examples and interactive quiz.

Documentation

  • Main file: docs/11-application-development/11.2.3-business-logic-patterns.md (22KB)
    • Transaction Script pattern (procedural approach for simple domains)
    • Domain Model pattern (OOP encapsulation for complex domains)
    • Service Layer pattern (orchestration and transaction boundaries)
    • Comparative analysis with decision criteria
    • Anti-patterns section (business logic scattered across layers)
    • Self-directed exercises

TypeScript Examples

Four complete projects demonstrating pattern application:

  1. Transaction Script - Order processing with procedural functions
  2. Domain Model - Rich domain objects (Order, Customer, Product, Coupon)
  3. Comparison - Same discount calculation problem solved both ways
  4. Service Layer - Orchestrates repositories, domain objects, and cross-cutting concerns

Each example includes:

  • Full TypeScript setup (tsconfig, package.json, jest)
  • Comprehensive tests (67 total across all examples)
  • Working demo with npm start
  • Detailed README

Example comparing approaches:

// Transaction Script - procedural
function calculateOrderDiscount(data: OrderData): number {
  let discount = 0;
  discount += calculateVolumeDiscount(data.orderTotal);
  discount += calculateCustomerDiscount(data.orderTotal, data.customerType);
  discount += applyCouponDiscount(data.orderTotal, data.couponCode);
  return Math.min(discount, data.orderTotal * 0.40);
}

// Domain Model - encapsulated behavior
class Order {
  calculateDiscount(): number {
    return this.discountPolicy.calculateTotalDiscount(this);
  }
}

Interactive Quiz

10 questions testing pattern selection decisions and trade-off understanding following quizdown format at src/quizzes/chapter-11/11.2.3/business-logic-patterns-quiz.js.

Front-matter

Standard bootcamp metadata configured:

  • Category: Software Development
  • Reading time: 30 minutes
  • Exercise: 90 minutes
  • Technologies: TypeScript, Design Patterns
Original prompt

This section details on the original issue you should resolve

<issue_title>Task 2.0: Business Logic Patterns Documentation and Examples (11.2.3)</issue_title>
<issue_description>## 🎯 Task Overview

Task ID: 2.0
Parent Spec: docs/specs/01-spec-design-patterns-section/01-spec-design-patterns-section.md
Depends On: Task 1.0 (conceptually independent, but sequential for consistency)
Status: Ready for Implementation
Estimated Time: 1-2 hours

This task implements comprehensive documentation for Business Logic Patterns (11.2.3), including Transaction Script, Domain Model, and Service Layer patterns with working TypeScript examples and an interactive quiz.


📋 Specification Context

Project Overview

This specification defines the remaining Design Patterns subsections for Chapter 11 (Application Development) of the DevOps Bootcamp. This task focuses on patterns for organizing business logic, helping students understand trade-offs between simplicity and complexity management.

User Story

US-3: Organizing Business Logic
As a developer facing design decisions, I want to understand when to use Transaction Script versus Domain Model patterns so that I can choose the appropriate approach for my application's complexity.

Functional Requirements

ID Requirement
U3-FR1 The system shall explain Transaction Script Pattern with examples showing procedural organization of business logic
U3-FR2 The system shall explain Domain Model Pattern with examples showing object-oriented encapsulation of business rules
U3-FR3 The system shall provide comparative examples solving the same business problem with both Transaction Script and Domain Model approaches
U3-FR4 The system shall include decision guidance on pattern selection based on domain complexity, team experience, and maintenance expectations
U3-FR5 The system shall demonstrate Service Layer pattern for orchestrating domain objects and transaction boundaries
U3-FR6 The system shall include anti-patterns showing business logic scattered across layers
U3-FR7 The system shall provide a self-directed exercise for students to implement business logic using the pattern appropriate for given complexity
U3-FR8 The system shall include an interactive quiz testing conceptual understanding and decision-making for business logic patterns

✅ Acceptance Criteria (Proof Artifacts)

The following artifacts must exist and be verified for task completion:

  • Documentation: docs/11-application-development/11.2.3-business-logic-patterns.md exists with complete content including front-matter, pattern explanations, comparative analysis, and exercises
  • Transaction Script: examples/ch11/business-patterns/transaction-script/ contains working TypeScript implementation with README showing procedural organization
  • Domain Model: examples/ch11/business-patterns/domain-model/ contains working TypeScript implementation with README showing OOP encapsulation
  • Comparative Example: examples/ch11/business-patterns/comparison/ contains same business problem solved with both patterns, with README explaining trade-offs
  • Service Layer: examples/ch11/business-patterns/service-layer/ contains working TypeScript implementation with README demonstrating orchestration
  • Quiz: src/quizzes/chapter-11/11.2.3/business-logic-patterns-quiz.js exists with decision-making questions following quizdown format
  • CLI Verification: npm test passes in all example directories
  • Integration Verification: Quiz renders correctly in Docsify when served with npm start

📝 Sub-tasks

Documentation Tasks

  • 2.1 Create documentation file docs/11-application-development/11.2.3-business-logic-patterns.md with front-matter (category: Application Development, technologies: TypeScript/Design Patterns, estReadingMinutes: 30, exercise definition)
  • 2.2 Write Transaction Script Pattern section explaining procedural organization of business logic, benefits (simplicity, directness), and when to use it (simple domains)
  • 2.3 Write Domain Model Pattern section explaining object-oriented encapsulation of business rules, benefits (rich behavior, maintainability), and when to use it (complex domains)
  • 2.4 Write Service Layer Pattern section explaining orchestration of domain objects, transaction boundaries, and API exposure patterns
  • 2.5 Write comparative analysis section contrasting Transaction Script vs Domain Model with decision criteria based on complexity, team experience, and maintenance expectations
  • 2.6 Write anti-patterns section showing business logic scattered across layers (controllers, views, data access)
  • 2.7 Add self-directed exercise description for implementing business logic using pattern appropriate for given complexity level

Code Examp...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 5, 2026 23:44
…c patterns

Co-authored-by: jburns24 <19497855+jburns24@users.noreply.github.com>
Co-authored-by: jburns24 <19497855+jburns24@users.noreply.github.com>
Co-authored-by: jburns24 <19497855+jburns24@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Business Logic Patterns documentation and examples Add Business Logic Patterns documentation and TypeScript examples (11.2.3) Jan 6, 2026
Copilot AI requested a review from jburns24 January 6, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task 2.0: Business Logic Patterns Documentation and Examples (11.2.3)

2 participants