Skip to content

Code Review#7

Open
jackc108 wants to merge 1 commit into
cfrantzidis:masterfrom
jackc108:master
Open

Code Review#7
jackc108 wants to merge 1 commit into
cfrantzidis:masterfrom
jackc108:master

Conversation

@jackc108

Copy link
Copy Markdown

No description provided.

@jackc108 jackc108 changed the title Code Rreview Code Review Jul 28, 2025
@jackc108

Copy link
Copy Markdown
Author

Naming:

Variable names like z, q, a, s, t, w, and e are too cryptic and lack meaning.
The class Program is fine (standard in console apps), but method and variable names should be more descriptive.

Suggestions:
Rename z → filePath, q → fileLines, a → wordFrequency, s → cleanedLine, t → words, w → word, e → entry.
Use PascalCase for method names if adding more methods later.

Structure:

Everything is placed inside the Main method.
No separation of logic: reading files, processing text, and displaying output are all mixed together.

Suggestions:
Break the code into smaller methods, makes testing and reuse easier

Error Handling:

No error handling for:
file not found, empty input, file access issues

Could crash if file path is invalid.

Suggestions:
Wrap file reading in a try-catch block.
Validate user input before accessing the file.

File Assumptions:

Assumes the user inputs a valid path and the file exists.
Assumes the file is plain text and small enough to fit into memory.

Suggestions:
Add validation and error messages.
Consider using File.ReadLines for large files (streaming instead of loading all at once).

OOP Principles:

Entire logic is procedural.
No classes, encapsulation, or reuse potential.

Suggestions:
Create a class like WordCounter with methods and encapsulated state if needed.
This would improve readability and scalability

Output:

Output is functional but plain.
"Done" and "uniquez" are unclear labels.

Suggestions:
Use clearer messaging like:
"Finished counting words."
"Total unique words: 42"

Consider formatting output in columns for better readability.

Program Logic:

Logic for word counting is correct and basic.
Removes punctuation, converts to lowercase, and splits by spaces.

Suggestions:
Regex.Replace(q[i],@"[^\w\s]", "") is good, but doesn’t catch hyphenated or compound words well.
Could consider more robust tokenization using \b word boundaries or a tokenizer library.

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