π― Learning Objectives
By the end of this module, you will:
- Create custom system prompts following proven patterns and structures
- Apply progressive learning behaviors using
@behaviour-progressive-learning
- Transform technical rules into educational content systematically
- Design interactive learning experiences with assessments and exercises
- Master advanced AI-powered development workflows for team knowledge sharing
π Module Overview
Duration: 4 hours
Difficulty: Advanced
Prerequisites: All previous modules completed, understanding of learning design
This capstone module teaches you to create your own system prompts and educational content. You'll learn the meta-skills of prompt engineering and instructional design, enabling you to build AI-powered learning systems for any technical domain.
πΊοΈ Learning Path
Lesson 7.1: System Prompt Architecture (60 minutes)
π― Learning Objectives:
- Understand the anatomy of effective system prompts
- Learn prompt engineering best practices
- Design reusable prompt templates
π Core Concepts:
System Prompt Structure:
- Metadata: Author, version, purpose
- Role Definition: AI persona and expertise level
- Goal Statement: Clear, actionable objectives
- Constraints: Boundaries and limitations
- Output Format: Structured response requirements
- Examples: Concrete demonstrations
π‘ Knowledge Check:
What makes a system prompt effective vs. ineffective?
Answer: Effective prompts are specific, structured, include constraints, provide examples, and have clear success criteria. Ineffective prompts are vague, lack structure, have no constraints, and don't specify desired outputs.
π§ Hands-on Exercise 7.1:
Scenario: Create a system prompt for automated code review.
Step 1: Analyze Existing Prompts
Study the structure of existing prompts like @124-java-secure-coding.md
:
---
author: Juan Antonio BreΓ±a Moral
version: 0.11.0-SNAPSHOT
---
# Java Secure Coding
## Role
You are a Senior software engineer with extensive experience in Java security
## Goal
Review Java code for security vulnerabilities and apply OWASP best practices
## Constraints
- Focus only on security issues
- Provide specific code examples
- Include severity ratings (HIGH/MEDIUM/LOW)
- Reference OWASP guidelines
## Output Format
- **Security Issues Found**: List with severity
- **Recommended Fixes**: Code examples
- **Prevention Strategies**: Best practices
Step 2: Create Custom System Prompt
Template: Code Review System Prompt
---
author: [Your Name]
version: 1.0.0
---
# Java Code Review Assistant
## Role
You are a Senior Java Developer and Code Review Expert with 10+ years of experience in enterprise software development, specializing in code quality, maintainability, and best practices.
## Goal
Perform comprehensive code reviews focusing on:
- Code quality and maintainability
- Design pattern application
- Performance considerations
- Testing adequacy
- Documentation completeness
## Constraints
- **MANDATORY**: Provide specific line-by-line feedback
- **FOCUS**: Constructive criticism with actionable improvements
- **SCOPE**: Java code only (exclude configuration files unless critical)
- **STYLE**: Professional, educational tone
- **EXAMPLES**: Include before/after code samples for major suggestions
## Analysis Framework
### 1. Code Quality Assessment
- **Readability**: Clear variable names, method structure
- **Maintainability**: SOLID principles, low coupling
- **Consistency**: Code style, naming conventions
- **Complexity**: Cyclomatic complexity, method length
### 2. Design Evaluation
- **Architecture**: Layer separation, dependency injection
- **Patterns**: Appropriate design pattern usage
- **Abstraction**: Interface vs. implementation
- **Extensibility**: Future modification ease
### 3. Performance Review
- **Efficiency**: Algorithm complexity, resource usage
- **Memory**: Object creation, garbage collection impact
- **Concurrency**: Thread safety, synchronization
- **Database**: Query optimization, N+1 problems
### 4. Testing Analysis
- **Coverage**: Unit test completeness
- **Quality**: Test readability, assertion clarity
- **Strategy**: Test pyramid adherence
- **Mocking**: Appropriate mock usage
## Output Format
### Executive Summary
- **Overall Rating**: Excellent/Good/Needs Improvement/Poor
- **Key Strengths**: Top 3 positive aspects
- **Critical Issues**: Must-fix problems (if any)
- **Improvement Priority**: High/Medium/Low categorized suggestions
### Detailed Review
#### π Code Quality Issues
For each issue:
- **Location**: File:LineNumber
- **Severity**: HIGH/MEDIUM/LOW
- **Issue**: Clear description
- **Impact**: Why this matters
- **Recommendation**: Specific fix with code example
#### π‘ Suggestions for Improvement
- **Design Improvements**: Architecture suggestions
- **Performance Optimizations**: Efficiency gains
- **Testing Enhancements**: Coverage and quality improvements
- **Documentation**: Missing or unclear documentation
#### β
Positive Observations
- **Good Practices**: What's working well
- **Effective Patterns**: Well-implemented solutions
- **Quality Code**: Examples of excellent implementation
### Code Examples
#### Before (Current Code)
```java
// Original code with issues
After (Recommended Improvement)
// Improved version with explanations
Next Steps
- Immediate Actions: Critical fixes required
- Short-term Improvements: Next sprint considerations
- Long-term Enhancements: Future architectural improvements
- Learning Resources: Relevant documentation/articles
Validation Checklist
- [ ] All major issues identified and explained
- [ ] Constructive feedback provided
- [ ] Code examples included for significant changes
- [ ] Priority levels assigned to recommendations
- [ ] Educational value included (explain the "why")
#### π **Prompt Design Principles:**
- **Specificity**: Clear, unambiguous instructions
- **Structure**: Organized, scannable format
- **Examples**: Concrete demonstrations
- **Constraints**: Clear boundaries and limitations
- **Validation**: Success criteria and checkpoints
---
### **Lesson 7.2: Progressive Learning Behavior Application** (90 minutes)
#### π― **Learning Objectives:**
- Apply the `@behaviour-progressive-learning` behavior effectively
- Transform technical system prompts into educational content
- Design interactive learning experiences
#### π **Core Concepts:**
**Progressive Learning Structure:**
1. **Extract**: Core concepts from technical content
2. **Structure**: Learning modules with prerequisites
3. **Create**: Interactive exercises and examples
4. **Generate**: Comprehensive courses with assessments
5. **Provide**: Knowledge validation checkpoints
#### π§ **Hands-on Exercise 7.2:**
**Scenario:** Transform the code review system prompt into a learning course.
**Step 1: Apply Progressive Learning Behavior**
Use: `Create a course about the code review system prompt using the behavior @behaviour-progressive-learning and put the course here @site-generator/content/courses/system-prompts-java/module-7-advanced-patterns/`
**Expected Course Structure:**
```markdown
# Mastering Java Code Reviews - From Checklist to Expertise
## π― Course Overview
**Transform your code review skills** from basic checklist-following to expert-level analysis that improves code quality, team knowledge sharing, and software maintainability.
### π Learning Objectives
- Perform systematic code quality assessments
- Identify design pattern opportunities and anti-patterns
- Evaluate performance implications of code changes
- Provide constructive, educational feedback
- Build team code review culture
### π Module Breakdown
#### Module 1: Code Review Foundations (2 hours)
- **Learning Objectives**: Understand code review purpose and benefits
- **Core Concepts**: Quality metrics, review types, feedback principles
- **Exercise**: Review a simple method with guided checklist
- **Assessment**: Identify 5 code quality issues in sample code
#### Module 2: Design Pattern Recognition (2.5 hours)
- **Learning Objectives**: Identify design patterns and anti-patterns
- **Core Concepts**: SOLID principles, common patterns, refactoring opportunities
- **Exercise**: Suggest design improvements for tightly coupled code
- **Assessment**: Propose design pattern solutions for 3 scenarios
#### Module 3: Performance Analysis (2 hours)
- **Learning Objectives**: Evaluate performance implications
- **Core Concepts**: Algorithm complexity, memory usage, concurrency
- **Exercise**: Identify performance bottlenecks in data processing code
- **Assessment**: Optimize code for better performance
#### Module 4: Effective Feedback (1.5 hours)
- **Learning Objectives**: Provide constructive, actionable feedback
- **Core Concepts**: Communication principles, educational feedback
- **Exercise**: Rewrite harsh feedback to be constructive
- **Assessment**: Create comprehensive review for complex class
### π Learning Progression
#### Foundation Level (Beginner)
- Focus on obvious issues (syntax, basic patterns)
- Use checklists and templates
- Practice with guided examples
#### Intermediate Level
- Recognize design patterns and anti-patterns
- Evaluate architectural decisions
- Provide educational explanations
#### Expert Level
- Anticipate future maintenance issues
- Suggest architectural improvements
- Mentor others through reviews
### π Assessment Strategy
#### Knowledge Checks
- "What's the difference between code review and code inspection?"
- "How do you balance thoroughness with review velocity?"
- "When should you suggest refactoring vs. accepting current implementation?"
#### Practical Exercises
- **Exercise 1**: Review calculator class for basic issues
- **Exercise 2**: Analyze service layer for design patterns
- **Exercise 3**: Evaluate data processing pipeline for performance
- **Exercise 4**: Provide comprehensive review for complete feature
#### Capstone Project
**"Complete Code Review Portfolio"**
- Review 5 different types of Java classes
- Demonstrate all review aspects (quality, design, performance, testing)
- Create educational feedback that helps junior developers learn
- Document review methodology and rationale
### π‘ Interactive Elements
#### Before/After Comparisons
```java
// BEFORE: What issues do you see?
public class UserService {
public String processUser(String data) {
String[] parts = data.split(",");
// ... problematic implementation
}
}
// AFTER: Improved version
public class UserService {
public ProcessingResult processUser(UserData userData) {
// ... improved implementation with explanation
}
}
Guided Analysis
- "Notice how this method violates Single Responsibility - it's parsing, validating, and persisting data"
- "This connects to our earlier lesson on SOLID principles - remember the 'S' in SOLID?"
Real-World Scenarios
- "You're reviewing a junior developer's first Spring Boot controller. How do you provide feedback that's educational but not overwhelming?"
- "The code works but uses deprecated APIs. How do you prioritize this feedback?"
π― Learning Paths
Quick Professional (4 hours)
- Module 1: Foundations (1 hour)
- Module 4: Effective Feedback (1 hour)
- Practical exercises (2 hours)
Comprehensive Mastery (8 hours)
- All modules with deep exercises
- Capstone project completion
- Peer review practice
Team Lead Track (6 hours)
- Focus on building review culture
- Mentoring through reviews
- Process optimization
Which path matches your current needs and available time?
#### π‘ **Educational Transformation Benefits:**
- **Systematic Learning**: Structured progression from basics to advanced
- **Interactive Practice**: Hands-on exercises with real code
- **Assessment Validation**: Knowledge checkpoints ensure understanding
- **Multiple Paths**: Different learning styles and time constraints
- **Real-World Application**: Immediately applicable skills
---
### **Lesson 7.3: Custom Learning Experience Design** (90 minutes)
#### π― **Learning Objectives:**
- Design complete learning experiences from scratch
- Create interactive exercises and assessments
- Apply instructional design principles to technical content
#### π§ **Hands-on Exercise 7.3:**
**Project:** Create a complete learning module for "Java Memory Management"
**Step 1: Define Learning Objectives**
```markdown
## Learning Objectives
By the end of this module, learners will:
- Understand JVM memory structure (heap, stack, metaspace)
- Identify memory leaks and their causes
- Apply memory optimization techniques
- Use profiling tools to analyze memory usage
- Implement memory-efficient coding patterns
Step 2: Design Progressive Structure
### Module Structure
#### Lesson 1: JVM Memory Fundamentals (45 minutes)
- **Concept**: Heap vs Stack vs Metaspace
- **Exercise**: Analyze memory allocation for different object types
- **Assessment**: Diagram memory layout for sample program
#### Lesson 2: Garbage Collection (60 minutes)
- **Concept**: GC algorithms and tuning
- **Exercise**: Compare GC logs from different collectors
- **Assessment**: Recommend GC settings for specific scenarios
#### Lesson 3: Memory Leak Detection (75 minutes)
- **Concept**: Common leak patterns and detection
- **Exercise**: Find and fix memory leaks in sample applications
- **Assessment**: Create comprehensive leak detection checklist
#### Lesson 4: Optimization Techniques (60 minutes)
- **Concept**: Memory-efficient coding patterns
- **Exercise**: Refactor memory-intensive code
- **Assessment**: Design memory-efficient data processing pipeline
Step 3: Create Interactive Elements
### Interactive Learning Components
#### π Knowledge Checks
- "What happens to objects when they go out of scope?"
- "Why might a HashMap cause memory leaks?"
- "When should you use WeakReference vs SoftReference?"
#### π‘ Visual Learning
```ascii
JVM Memory Structure:
βββββββββββββββββββββββββββββββββββββββ
β Heap Memory β
β βββββββββββββββ βββββββββββββββ β
β β Young Gen β β Old Gen β β
β β (Eden+S0+S1)β β β β
β βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ
β Stack Memory β
β βββββββββββββββ βββββββββββββββ β
β β Thread 1 β β Thread 2 β β
β β Stack β β Stack β β
β βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββ
π― Practical Challenges
Challenge 1: Memory Leak Detective
// Find the memory leak in this code
public class UserCache {
private static final Map<String, User> cache = new HashMap<>();
public static void cacheUser(User user) {
cache.put(user.getId(), user);
}
public static User getUser(String id) {
return cache.get(id);
}
}
Challenge 2: Optimization Opportunity
// Optimize this code for better memory usage
public List<String> processLargeFile(String filename) {
List<String> allLines = Files.readAllLines(Paths.get(filename));
List<String> processed = new ArrayList<>();
for (String line : allLines) {
if (line.startsWith("ERROR")) {
processed.add(line.toUpperCase());
}
}
return processed;
}
π Capstone Project
"Memory-Efficient Data Pipeline"
- Design a system that processes 1GB+ files with <512MB heap
- Implement streaming processing with backpressure
- Add memory monitoring and alerting
- Create comprehensive documentation
---
### **Lesson 7.4: Advanced AI Workflow Integration** (60 minutes)
#### π― **Learning Objectives:**
- Integrate multiple system prompts into cohesive workflows
- Create compound AI-powered development processes
- Design team collaboration patterns with AI assistance
#### π **Core Concepts:**
**AI Workflow Patterns:**
1. **Sequential Processing**: Chain prompts for complex tasks
2. **Parallel Analysis**: Multiple prompts analyze different aspects
3. **Iterative Refinement**: Feedback loops with AI assistance
4. **Collaborative Review**: Team + AI collaborative workflows
#### π§ **Hands-on Exercise 7.4:**
**Scenario:** Design a complete AI-powered development workflow.
**Workflow: "Feature Development Pipeline"**
```markdown
## AI-Powered Feature Development Workflow
### Phase 1: Requirements Analysis
1. **Prompt**: `@170-java-documentation` - Generate feature specification
2. **Input**: User story and acceptance criteria
3. **Output**: Detailed technical specification with API design
### Phase 2: Design & Architecture
1. **Prompt**: `@171-java-diagrams` - Create architecture diagrams
2. **Prompt**: `@121-java-object-oriented-design` - Design class structure
3. **Output**: UML diagrams and detailed design document
### Phase 3: Implementation
1. **Prompt**: `@128-java-generics` - Implement type-safe components
2. **Prompt**: `@142-java-functional-programming` - Add functional processing
3. **Prompt**: `@124-java-secure-coding` - Apply security best practices
### Phase 4: Testing & Quality
1. **Prompt**: `@131-java-unit-testing` - Generate comprehensive tests
2. **Prompt**: `@151-java-performance-jmeter` - Create performance tests
3. **Prompt**: Custom code review prompt - Automated code review
### Phase 5: Performance & Optimization
1. **Prompt**: `@161-java-profiling-detect` - Set up profiling
2. **Prompt**: `@162-java-profiling-analyze` - Analyze results
3. **Prompt**: `@164-java-profiling-compare` - Validate improvements
### Phase 6: Documentation & Knowledge Sharing
1. **Prompt**: `@170-java-documentation` - Generate final documentation
2. **Prompt**: `@behaviour-progressive-learning` - Create learning materials
3. **Output**: Complete feature with documentation and training materials
π‘ Advanced Integration Patterns:
1. Conditional Workflows
IF performance_requirements_high THEN
USE @161-java-profiling-detect AND @162-java-profiling-analyze
ELSE
USE @131-java-unit-testing ONLY
2. Feedback Loops
1. Generate code with @142-java-functional-programming
2. Review with custom code review prompt
3. IF issues_found THEN refine and repeat
4. ELSE proceed to testing phase
3. Team Collaboration
Developer A: Uses @128-java-generics for core implementation
Developer B: Uses @131-java-unit-testing for test coverage
Tech Lead: Uses custom code review prompt for final review
Team: Uses @behaviour-progressive-learning for knowledge sharing
π Module Assessment
Capstone Project: "Complete AI-Powered Learning System"
Project: Create a comprehensive learning system for a Java topic of your choice.
Requirements:
1. Custom System Prompt: Design a specialized system prompt for your topic
2. Progressive Learning Course: Transform your prompt into a complete course
3. Interactive Elements: Include exercises, assessments, and knowledge checks
4. AI Workflow Integration: Design a development workflow using multiple prompts
5. Team Enablement: Create materials for team knowledge sharing
Deliverables:
- Custom system prompt following best practices
- Complete learning course with 4+ modules
- Interactive exercises and assessments
- AI workflow documentation
- Team adoption guide
Success Criteria:
- System prompt generates consistent, high-quality outputs
- Course follows progressive learning principles
- Interactive elements engage learners effectively
- Workflow integrates multiple AI capabilities
- Materials enable effective team knowledge transfer
Time Investment:
- System Prompt Design: 2 hours
- Course Creation: 3 hours
- Interactive Elements: 2 hours
- Workflow Integration: 1.5 hours
- Team Materials: 1.5 hours
- Total: 10 hours
π Course Completion
Congratulations! You've completed the comprehensive Java System Prompts course.
π What You've Mastered
Technical Skills:
- β
Automated Maven project setup and configuration
- β
Comprehensive unit testing and design principles
- β
Security, concurrency, and production-ready coding
- β
Modern Java features and functional programming
- β
Performance optimization and systematic profiling
- β
Professional documentation and diagram generation
- β
Advanced system prompt creation and learning design
AI-Powered Workflows:
- β
25+ production-ready system prompts
- β
Interactive and non-interactive prompt usage
- β
Behavioral customization with consultative interaction
- β
Progressive learning content generation
- β
Complex workflow orchestration
- β
Team knowledge sharing automation
Meta-Skills:
- β
Prompt engineering and AI collaboration
- β
Instructional design for technical content
- β
Systematic problem-solving approaches
- β
Quality-first development mindset
- β
Continuous learning and improvement
π Your Next Steps
Immediate Application:
1. Apply in Current Projects: Use learned system prompts in your daily work
2. Team Introduction: Share knowledge with your development team
3. Custom Prompts: Create specialized prompts for your domain
4. Continuous Learning: Stay updated with new Java features and AI capabilities
Advanced Exploration:
- Contribute: Add new system prompts to the community repository
- Mentor: Teach others using progressive learning techniques
- Innovate: Develop new AI-powered development workflows
- Research: Explore emerging AI tools and integration patterns
π Continued Learning Resources
π Final Reflection
You've transformed from using basic system prompts to creating comprehensive AI-powered learning systems. This meta-skill of teaching AI to teach others is incredibly valuable in our rapidly evolving technological landscape.
Remember:
- Quality over Quantity: Focus on creating valuable, reusable prompts
- Team First: Share knowledge and build collective capabilities
- Continuous Improvement: Iterate and refine based on real-world usage
- Community Contribution: Share your innovations with the broader community
Welcome to the future of AI-powered Java development! π
Thank you for completing this comprehensive journey. Continue building amazing software with AI assistance, and remember to share your knowledge with others.