Skip to content

Code Review#8

Open
jackc108 wants to merge 2 commits into
cfrantzidis:masterfrom
jackc108:master
Open

Code Review#8
jackc108 wants to merge 2 commits into
cfrantzidis:masterfrom
jackc108:master

Conversation

@jackc108

Copy link
Copy Markdown

No description provided.

@jackc108

Copy link
Copy Markdown
Author

Naming:

Variable and method names are much more descriptive in this version.
filePath, lines, wordCounts, cleanedLine, and words are clear and meaningful.
Class and method names follow C# conventions.

Suggestions:
Maybe rename pair in the foreach loop to something slightly more descriptive, like wordEntry or entry.

Code Structure:

Clearly separates: user input → file validation → text processing → output.
Still, everything is inside Main, which limits testability and reusability.

Suggestions:
Extract core logic into methods:
ReadFile(string path)
Dictionary<string, int> CountWords(string[] lines)
void PrintResults(Dictionary<string, int> wordCounts)

Error Handling:

Checks if the file exists and exits gracefully if it doesn’t.
Still no handling for edge cases like:
Empty file
File read exceptions (e.g., permission issues, corrupted files)

Suggestions:
Add feedback if the file is empty or contains no words.

File Assumptions:

Still assumes a valid, readable text file.
Better than the previous because of file existence check.

Suggestions:
Add basic validation for:
File being non-empty
Proper encoding (if encoding issues are possible)

OOP Principles:

Code is still procedural, all within the Main method.
No actual use of OOP (objects, classes, encapsulation), though unnecessary for such a small script.

Suggestions:
Encapsulate the logic in a class, although only really needed if the app is expanding

Output:

Clear, readable output.
Sorted output is a nice touch (OrderBy(p => p.Key)).
Good message for unique word count.

Suggestions:
Improve spacing or formatting for alignment

Program Logic:

Word counting logic is good.
Cleans input, splits on whitespace, ignores punctuation, case-insensitive.

Suggestions:
Support Unicode punctuation better with \p{P} in regex.
Allow ignoring stopwords or apply stemming (if this was a larger project).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant