-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor codebase with functional programming principles #3
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,11 @@ | ||||||||||||
| using System.Text; | ||||||||||||
| using System.Collections.Immutable; | ||||||||||||
| using CodeContext.Configuration; | ||||||||||||
|
|
||||||||||||
| namespace CodeContext.Services; | ||||||||||||
|
|
||||||||||||
| /// <summary> | ||||||||||||
| /// Builds project context content based on configuration. | ||||||||||||
| /// Builds project context content using functional composition. | ||||||||||||
| /// Separates content generation from assembly. | ||||||||||||
| /// </summary> | ||||||||||||
| public class ContentBuilder | ||||||||||||
| { | ||||||||||||
|
|
@@ -17,26 +18,51 @@ public ContentBuilder(ProjectScanner scanner) | |||||||||||
|
|
||||||||||||
| /// <summary> | ||||||||||||
| /// Builds the complete content output including structure and file contents. | ||||||||||||
| /// Uses functional composition to build content sections. | ||||||||||||
| /// </summary> | ||||||||||||
| /// <param name="projectPath">The directory path to process.</param> | ||||||||||||
| /// <param name="config">The configuration specifying what to include.</param> | ||||||||||||
| /// <returns>The complete output content.</returns> | ||||||||||||
| public string Build(string projectPath, AppConfig config) | ||||||||||||
| public string Build(string projectPath, AppConfig config) => | ||||||||||||
| string.Join("\n", BuildContentSections(projectPath, config)); | ||||||||||||
|
|
||||||||||||
| /// <summary> | ||||||||||||
| /// Pure function that generates content sections based on configuration. | ||||||||||||
| /// Uses declarative approach with LINQ and immutable collections. | ||||||||||||
|
||||||||||||
| /// Pure function that generates content sections based on configuration. | |
| /// Uses declarative approach with LINQ and immutable collections. | |
| /// Generates content sections based on configuration using a declarative approach. | |
| /// Builds a lazy evaluation structure: the returned delegates will perform I/O when evaluated. | |
| /// Uses LINQ and immutable collections to assemble content sections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment claims
ParseConfigis a "pure function", but it can throw exceptions and has different behavior based on the input JSON structure. Additionally, catchingJsonExceptionand returning a default config means it has side effects (writing to console via the caller). Consider updating the documentation to reflect that this function has side effects or error-handling behavior.