Skip to content

Code Review – CMP1903M Resit Assessment#8

Open
jesse1234-cyber wants to merge 2 commits into
cfrantzidis:masterfrom
jesse1234-cyber:master
Open

Code Review – CMP1903M Resit Assessment#8
jesse1234-cyber wants to merge 2 commits into
cfrantzidis:masterfrom
jesse1234-cyber:master

Conversation

@jesse1234-cyber

Copy link
Copy Markdown
  1. Naming
    Variable names like z, q, a, s, and t are not meaningful.
    Suggest renaming:
    z → File Path
    q → lines
    a → wordcounts
    s → cleaned Line
    t → words

  2. Code Structure
    Entire logic is written inside the main() method.
    This breaks modularity and reusability.
    Suggest creating separate methods:
    Read File() Process Words() Display Results()`

  3. Error Handling
    No handling for invalid file paths or read errors.
    Program crashes if file is missing.
    Suggesting that wrapping File.ReadAllLines(z) in a try-catch block to show a user-friendly error message.

  4. File Assumptions
    No validation or checks for empty lines or invalid content.
    Suggest checking if file exists and has content before processing.

  5. OOP Principles
    The program is purely procedural.
    No use of classes or encapsulation.
    suggested that introducing a Word Processor or Word Counter class with clear responsibilities Single Responsibility Principle.

  6. Output
    The output is functional but basic.
    Suggest:
    Sorting the dictionary alphabetically or by frequency
    Formatting output using Console. WriteLine($"{word}: {count}")

  7. Program Logic
    Logic is correct: reads lines, cleans words, counts, and displays results.
    Regex and dictionary usage is appropriate.
    Could be optimized slightly by trimming whitespace and removing unnecessary checks.

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