Skip to content

Commit 17bfab2

Browse files
claudeDavidVeksler
authored andcommitted
Refactor: Maximize self-documentation through comprehensive code modernization
This refactor dramatically improves code clarity, maintainability, and self-documentation by eliminating boilerplate, removing redundancy, and restructuring logic for transparency. ### New Utility Classes - **Guard.cs**: Centralized parameter validation eliminating 30+ lines of boilerplate - **GitHelper.cs**: Unified Git repository detection (eliminates 2 duplicate implementations) ### New Service Classes (Extracted from Program.cs) - **AppConfig.cs**: Application configuration record (moved to Configuration/) - **ConfigLoader.cs**: JSON configuration loading with error handling - **OutputFormatter.cs**: File output with multiple format support - **StatsCalculator.cs**: Processing statistics calculation - **PathResolver.cs**: Path validation and user input handling - **ContentBuilder.cs**: Project content assembly orchestration ### Code Improvements - **Program.cs**: Reduced from 268 to 71 lines (-73%) with pure DI orchestration - **ProjectScanner.cs**: Uses Guard and GitHelper, improved naming (path → projectPath) - **FileFilterService.cs**: Uses Guard and GitHelper, removed duplicate FindGitRepoRoot - **FileUtilities.cs**: Uses Guard for validation ### Deleted Deprecated Classes - Removed MyAppsContext.cs (obsolete facade) - Removed FileChecker.cs (obsolete facade) - Removed FileUtils.cs (obsolete facade) ### Self-Documentation Improvements - Consistent parameter naming (projectPath vs path/rootPath) - Clear variable names (structure, fileContents vs sb, results) - Expressive method extraction (single responsibility) - Pure dependency injection (no static facades) - Obvious data flow through constructor injection ### Impact - 8 new focused classes with single responsibilities - Eliminated all validation boilerplate through Guard - Removed all code duplication (Git helpers, validation) - Program.cs is now pure orchestration (73% reduction) - Clear, testable, maintainable architecture - Zero functional changes - backward compatible
1 parent 812b957 commit 17bfab2

15 files changed

Lines changed: 475 additions & 453 deletions

Configuration/AppConfig.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace CodeContext.Configuration;
2+
3+
/// <summary>
4+
/// Application configuration loaded from config.json.
5+
/// </summary>
6+
public record AppConfig
7+
{
8+
public string DefaultInputPath { get; init; } = ".";
9+
public string DefaultOutputFileName { get; init; } = "context.txt";
10+
public string OutputFormat { get; init; } = "text";
11+
public bool IncludeStructure { get; init; } = true;
12+
public bool IncludeContents { get; init; } = true;
13+
}

FileChecker.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

FileUtils.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

MyAppsContext.cs

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)