-
Notifications
You must be signed in to change notification settings - Fork 53
Add Data Layer Patterns documentation and Go examples (11.2.2) #817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Create a starter project for Exercise 1 in the Data Layer Patterns documentation that demonstrates the anti-pattern of direct data access scattered throughout the codebase. This will serve as the "before" state that participants need to refactor. Requirements
Key Principles
Todo List
|
Created the exercise starter project in commit c17623e. Starter Project (
Updated Exercise Instructions:
The starter code demonstrates realistic legacy code patterns that students will need to identify and refactor on their own. |
|
@copilot We need to add a "Deliverable" section to docs/11-application-development/11.2.2-data-layer-patterns.md Look at the following sections for examples of what good deliverables look like
This is an example of bad deliverables
|
Added Deliverables section in commit ff38f5b. The section includes 7 questions that:
Questions encourage critical thinking about architectural decisions rather than just recalling facts. |
…Record, Optimistic/Pessimistic Locking) Co-authored-by: jburns24 <19497855+jburns24@users.noreply.github.com>
… examples Co-authored-by: jburns24 <19497855+jburns24@users.noreply.github.com>
- Create starter project with anti-patterns (direct SQL in handlers, no abstraction) - Demonstrate tightly coupled code with duplicated queries - Mix business logic with data access throughout handlers - Update exercise instructions to use leading questions instead of step-by-step solution - Remove specific implementation steps to encourage critical thinking Co-authored-by: jburns24 <19497855+jburns24@users.noreply.github.com>
- Add 7 deliverable questions testing pattern understanding and application - Questions focus on decision-making, trade-offs, and practical scenarios - Cover Repository vs Active Record comparison, SOLID principles connection - Address concurrency patterns and their real-world application - Include questions about testability improvements and multi-database support Co-authored-by: jburns24 <19497855+jburns24@users.noreply.github.com>
…tion, and broken quiz
…Separating interface from implementation creating an easier to understand repository. Also practicing practice of least surprise and changes repository implementations from mutating the input object
Fix race condition where concurrent goroutines received different database connections, each seeing isolated :memory: databases. This caused "no such table" errors during concurrent operations. Changes: - Use file::memory:?cache=shared for true shared in-memory databases - Enable WAL mode for better concurrent write performance - Set connection pool to 10 for realistic concurrent access - Enhance optimistic locking retry logic to handle database locks (5 retries, exponential backoff) - Fix pessimistic locking to actually acquire row locks via dummy UPDATE - Add educational comments explaining SQLite's table-level write lock limitations Results: - Optimistic locking: 10/10 operations succeed with retry handling - Pessimistic locking: 1-2 operations succeed (expected due to SQLite limitations) - Both examples now demonstrate true concurrent behavior without table errors
- Add inline exercises for Repository and Active Record patterns - Add new exercise for AI-assisted refactoring with Spec-Driven Development - Emphasize using proper vocabulary when working with AI agents - Update front-matter metadata with all new exercises including AI collaboration - Fix markdown linting error (multiple blank lines) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
e96be74 to
80065c8
Compare
Implements comprehensive documentation for Data Layer Patterns (Repository, Active Record, Optimistic/Pessimistic Locking) with working Go examples, interactive quiz, hands-on refactoring exercise, and deliverables section as specified in Task 1.0.
Documentation (
docs/11-application-development/11.2.2-data-layer-patterns.md)Go Examples (
examples/ch11/data-patterns/)Five self-contained examples with comprehensive tests (all passing):
Repository Pattern (
repository/):Active Record Pattern (
active-record/):Optimistic Locking (
concurrency/optimistic/):Pessimistic Locking (
concurrency/pessimistic/):Exercise Starter (
repository-exercise-starter/):Refactoring Exercise
Exercise Starter Project (
examples/ch11/data-patterns/repository-exercise-starter/):Exercise Instructions (in documentation):
Deliverables
Added comprehensive deliverables section with 7 questions covering:
Quiz (
src/quizzes/chapter-11/11.2.2/)12 questions covering pattern recognition, concurrency scenarios, and decision-making trade-offs using quizdown format.
Configuration Updates
docs/_sidebar.md.markdownlint.jsonto support<quizdown>elements and table stylesdocs/README.mdOriginal prompt
This section details on the original issue you should resolve
<issue_title>Task 1.0: Data Layer Patterns Documentation and Examples (11.2.2)</issue_title>
<issue_description># GitHub Issue: Task 1.0 - Data Layer Patterns Documentation and Examples (11.2.2)
🎯 Task Overview
Task ID: 1.0
Parent Spec:
docs/specs/01-spec-design-patterns-section/01-spec-design-patterns-section.mdStatus: Ready for Implementation
Estimated Time: 2-3 hours
This task implements comprehensive documentation for Data Layer Patterns (11.2.2), including Repository, Active Record, and Concurrency patterns (Optimistic/Pessimistic Locking) with working Go 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. Building on the completed SOLID Principles foundation (11.2.1), this spec focuses on architectural patterns (data layer and business logic) and classical Gang of Four patterns that students will encounter in production applications.
User Story
US-1: Understanding Data Layer Patterns
As a bootcamp apprentice learning production development, I want to understand Repository and Active Record patterns so that I can structure data access logic in enterprise applications.
US-2: Managing Concurrent Data Access
As a developer building multi-user applications, I want to understand Optimistic and Pessimistic Locking patterns so that I can handle concurrent data modifications safely.
Functional Requirements
✅ Acceptance Criteria (Proof Artifacts)
The following artifacts must exist and be verified for task completion:
docs/11-application-development/11.2.2-data-layer-patterns.mdexists with complete content including front-matter, pattern explanations, decision guidance, and exercisesexamples/ch11/data-patterns/repository/contains working Go implementation with README, tests, and clear interface abstractionexamples/ch11/data-patterns/active-record/contains working Go implementation with README demonstrating domain objects with encapsulated data accessexamples/ch11/data-patterns/concurrency/optimistic/contains SQLite-based demonstration with README showing version-based conflict detectionexamples/ch11/data-patterns/concurrency/pessimistic/contains SQLite-based demonstration with README showing exclusive access controlsrc/quizzes/chapter-11/11.2.2/data-layer-patterns-quiz.jsexists with pattern recognition questions following quizdown formatgo test ./...passes in all example directoriesnpm start📝 Sub-tasks
Documentation Tasks
docs/11-application-development/11.2.2-data-layer-patterns.mdwith front-matter (category: Application Development, technologies: Go/SQLite/Design Patterns, estReadingMinutes: 45, exercise definition)💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.