How good it the following prompt: "Act as a senior software architect reviewing code for…
- User
How good it the following prompt: "Act as a senior software architect reviewing code for over-engineering and architectural violations. You're looking at code in isolation without full project context, so be cautious - the original author may have had valid reasons for their choices.
YOUR ANALYSIS TASKS:
-
Identify Over-Engineering - Flag with [OE-#]:
- OE-INTF: Unnecessary interfaces (single implementation, no testing/mocking justification)
- OE-INDIRECT: Redundant wrappers/proxies without cross-cutting concerns
- OE-PATTERN: Misapplied patterns (Factory for <3 variations, Strategy for single algorithm)
- OE-GENERAL: Premature generalization (unused config flags, speculative features)
- OE-BLOAT: Heavy dependencies for trivial tasks
-
Detect Architectural Violations - Flag with [AV-#]:
- AV-AUTO-REG: Auto-registration outside startup flow (DI setup in constructors/requests)
- AV-LIFECYCLE: Service setup in wrong scopes (repeated initialization)
- AV-BOUNDARY: Layer violations (UI→Domain, Infrastructure→Core)
- AV-CONFIG-SPRAWL: Configuration scattered across multiple sources
- AV-SHARED-STATE: Mutable state crossing bounded contexts
-
Propose Refactoring - Follow "Boy Scout Rule" (smallest safe steps):
- Remove/inline unused abstractions
- Collapse inheritance to composition/functions when polymorphism isn't used
- Centralize DI registration to startup
- Replace heavyweight libs with native alternatives
- DO NOT: Break public APIs, remove justified abstractions, introduce new dependencies
REQUIRED OUTPUT:
Assessment: Brief summary of architectural health and main issues
Findings: List each issue as:
- [ISSUE-ID] Description
- Risk: Why this matters
- Location: Quote specific code
Refactored Code: Show simplified version with
// CHANGEDcommentsChange Log:
Change Justification Risk Level Removed IFoo interface Single implementation, no testing benefit Medium Moved auto-reg to Startup.cs Prevent duplicate registrations Critical Fix Validation Notes: What tests/checks should be run to ensure safety
Context Limitations: What additional info could change these recommendations
SPECIAL CASES:
- If no issues found: "Code is appropriately engineered. No changes recommended."
- For critical violations: Prioritize fixes with clear "CRITICAL FIX" comments
- When uncertain: Add TODO comments explaining what needs verification
Remember: Your goal is constructive improvement while preserving functionality and respecting the original author's potential reasoning."
-
- Assistant
The prompt you've provided is exceptionally well-structured and detailed, making it an excellent guide for a senior software architect tasked with reviewing code. Below, I'll break down the strengths and provide some suggestions for further improvement.
Strengths:
-
Clarity and Structure:
- The prompt is well-organized with clear headings and tasks, making it easy to follow.
- YOUR ANALYSIS TASKS section breaks down the review process into manageable steps.
-
Specific Guidelines:
- Detailed descriptions of what constitutes over-engineering (OE) and architectural violations (AV) with specific flags (e.g., [OE-INTF], [AV-AUTO-REG]) help ensure consistency in the review.
- The Propose Refactoring section provides actionable steps and constraints, ensuring that changes are safe and minimal.
-
Required Output:
- The REQUIRED OUTPUT section specifies exactly what the reviewer needs to deliver, including an assessment, detailed findings, refactored code, a change log, validation notes, and context limitations. This ensures comprehensive and consistent reporting.
- The Change Log table format standardised the documentation of changes, which is excellent for tracking and communication.
-
Special Cases:
- The SPECIAL CASES section handles edge scenarios, such as when no issues are found, critical violations are present, or when the reviewer is uncertain. This ensures that all possible outcomes are addressed appropriately.
-
Balanced Approach:
- The prompt emphasises constructive improvement while also respecting the original author's decisions, which is crucial for maintaining a positive and collaborative review process.
Suggestions for Improvement:
-
Examples:
- Including a few short code examples for each type of over-engineering and architectural violation could help clarify what to look for. This is especially useful for less experienced reviewers.
-
Prioritisation Guidance:
- Adding a section on how to prioritise issues could be beneficial. For instance, critical fixes should be addressed immediately, while medium-risk issues could be scheduled for the next maintenance cycle.
-
Tooling Recommendations:
- Suggesting tools or linters that can automatically detect some of these issues might improve efficiency. For example, tools like SonarQube, ReSharper, or ESLint can help identify certain patterns of over-engineering or architectural violations.
-
Stakeholder Communication:
- Adding a section on how to communicate findings to the original author and other stakeholders could be beneficial. This might include tips on framing feedback constructively and documenting changes for team transparency.
-
Context Gathering:
- Since the review is done in isolation, adding a section on how to gather additional context when needed could be useful. This might include reaching out to the original author, reviewing related documentation, or examining connected components.
Example Improvement: Adding Code Examples
Identify Over-Engineering
-
OE-INTF: Unnecessary interfaces (single implementation, no testing/mocking justification)
- Example:
public interface ILogger { void Log(string message); } public class ConsoleLogger : ILogger { public void Log(string message) { Console.WriteLine(message); } } // [OE-INTF] There is only one implementation of ILogger, and there is no evidence of testing or mocking justification.
- Example:
-
OE-PATTERN: Misapplied patterns (Factory for <3 variations, Strategy for a single algorithm)
- Example:
public interface IProduct { void Use(); } public class ProductA : IProduct { public void Use() { /* implementation */ } } public class ProductFactory { public IProduct CreateProduct(string type) { if (type == "A") return new ProductA(); // No other types, misapplied factory pattern. // [OE-PATTERN] The factory pattern is misapplied as there is only one product type. } }
- Example:
Final Prompt with Improvements
**Act as a senior software architect reviewing code for over-engineering and architectural violations. You're looking at code in isolation without full project context, so be cautious - the original author may have had valid reasons for their choices.** **YOUR ANALYSIS TASKS:** 1. **Identify Over-Engineering** - Flag with [OE-#]: - **OE-INTF**: Unnecessary interfaces (single implementation, no testing/mocking justification) - **Example:** ```csharp public interface ILogger { void Log(string message); } public class ConsoleLogger : ILogger { public void Log(string message) { Console.WriteLine(message); } } // [OE-INTF] There is only one implementation of ILogger, and there is no evidence of testing or mocking justification. ``` - **OE-INDIRECT**: Redundant wrappers/proxies without cross-cutting concerns - **OE-PATTERN**: Misapplied patterns (Factory for <3 variations, Strategy for single algorithm) - **Example:** ```csharp public interface IProduct { void Use(); } public class ProductA : IProduct { public void Use() { /* implementation */ } } public class ProductFactory { public IProduct CreateProduct(string type) { if (type == "A") return new ProductA(); // No other types, misapplied factory pattern. // [OE-PATTERN] The factory pattern is misapplied as there is only one product type. } } ``` - **OE-GENERAL**: Premature generalization (unused config flags, speculative features) - **OE-BLOAT**: Heavy dependencies for trivial tasks 2. **Detect Architectural Violations** - Flag with [AV-#]: - **AV-AUTO-REG**: Auto-registration outside startup flow (DI setup in constructors/requests) - **AV-LIFECYCLE**: Service setup in wrong scopes (repeated initialization) - **AV-BOUNDARY**: Layer violations (UI→Domain, Infrastructure→Core) - **AV-CONFIG-SPRAWL**: Configuration scattered across multiple sources - **AV-SHARED-STATE**: Mutable state crossing bounded contexts 3. **Propose Refactoring** - Follow "Boy Scout Rule" (smallest safe steps): - Remove/inline unused abstractions - Collapse inheritance to composition/functions when polymorphism isn't used - Centralize DI registration to startup - Replace heavyweight libs with native alternatives - **DO NOT**: Break public APIs, remove justified abstractions, introduce new dependencies **REQUIRED OUTPUT:** **Assessment:** Brief summary of architectural health and main issues **Findings:** List each issue as: - **[ISSUE-ID]** Description - **Risk:** Why this matters - **Location:** Quote specific code **Refactored Code:** Show simplified version with `// CHANGED` comments **Change Log:** | Change | Justification | Risk Level | | ------------------ | ---------------------------------------------- | ------------- | | Removed IFoo interface | Single implementation, no testing benefit | Medium | | Moved auto-reg to Startup.cs | Prevent duplicate registrations | Critical Fix | **Validation Notes:** What tests/checks should be run to ensure safety **Context Limitations:** What additional info could change these recommendations **SPECIAL CASES:** - If no issues found: "Code is appropriately engineered. No changes recommended." - For critical violations: Prioritize fixes with clear "CRITICAL FIX" comments - When uncertain: Add TODO comments explaining what needs verification **Tooling Recommendations:** - Consider using tools like SonarQube, ReSharper, or ESLint to automatically detect some of these issues. **Stakeholder Communication:** - When providing feedback, frame it constructively and document changes for team transparency. **Context Gathering:** - If more context is needed, reach out to the original author, review related documentation, or examine connected components. Remember: Your goal is constructive improvement while preserving functionality and respecting the original author's potential reasoning.This improved prompt includes code examples, prioritisation guidance, tooling recommendations, and sections on stakeholder communication and context gathering to ensure a thorough and effective code review process.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.