Skip to content

Code review for CMP1903M Resit Assessment#6

Open
jesse1234-cyber wants to merge 1 commit into
cfrantzidis:masterfrom
jesse1234-cyber:master
Open

Code review for CMP1903M Resit Assessment#6
jesse1234-cyber wants to merge 1 commit into
cfrantzidis:masterfrom
jesse1234-cyber:master

Conversation

@jesse1234-cyber

Copy link
Copy Markdown
  1. Naming
    Strength: Code has some recognizable variable names like wordcounts and file Path.
    Issues:
    Variable names like s, t, and w are vague and not self-explanatory.
    Suggestions:
    Rename variables for better readability:
    s → cleaned Line
    t → words
    w → word
    lines → file Lines

  2. Code Structure
    Strength: Code logic is clear and performs as expected.
    Issues:
    Entire logic is inside the Main() method, which reduces modularity.
    Suggestions:
    Break the program into reusable methods like:
    Read File(string file Path)
    Process Lines(string[] lines)
    Display Wordcounts(Dictionary<string, int> wordcounts)

  3. Error Handling
    Strength: Basic file existence check using File.Exists().
    Issues:
    No exception handling for ReadiLine() or unexpected errors.
    Suggestions:
    Add messages to guide the user if the file path is invalid or empty.

  4. File Assumptions
    Issues:
    Assumes file exists and has valid content.
    Doesn’t check if lines are empty or if file is unreadable.
    Suggestions:
    Add user feedback for such conditions.

  5. OOP Principles
    Issues:
    Entire logic is in a single class with one method.
    Lacks encapsulation and separation of concerns.
    Suggestions:
    Apply basic OOP structure:
    class FileProcessor { string[] ReadFile(); }
    class WordAnalyzer { Dictionary<string,int> CountWords(); }
    class DisplayHelper { void ShowResults(); }
    This helps maintain, test, and extend the program.

  6. Output
    Strength: Output uses Console.WriteLine() for user interaction.
    Issues:
    Not formatted or sorted, making results harder to read.
    Suggestions:
    Display results alphabetically or by frequency.
    Use clear headings like: --- Word Frequency Results ---.

  7. Program Logic
    Strength: Functional and loops through lines correctly.
    Issues:
    Logic for punctuation removal and splitting is correct but could use comments.
    Suggestions:
    Add comments above critical logic blocks.

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