Skip to content

code review (resit)#12

Open
420sam wants to merge 2 commits into
cfrantzidis:masterfrom
420sam:master
Open

code review (resit)#12
420sam wants to merge 2 commits into
cfrantzidis:masterfrom
420sam:master

Conversation

@420sam

@420sam 420sam commented Jul 30, 2025

Copy link
Copy Markdown

Naming:

The variables are extremely lacking. In the code variables such as ‘X, q, and a’ are used.

Change to make - More descripting and meaningful names (to the program) are used.

a - WordCounts

q - Lines

s - CleanLine

t -Words

w - Word

z – FilePath

Code Structure:

The code structure is very poor, the logic that is used is not separated at all in sections, but all of the logic is in only one main method block.

Change to make - Methods that can be used (breaking down the main)

-read/ validate files

  • clean/ split lines

-counts words

Error handling:

With no error handling the program is fragile and crashes frequently with little to no messages that aid the user in fixing their mistakes.

Change to make - Code can be added to validate if the file exists and if not to give user feedback regarding that. This will have to be implemented after the file is mentioned but before the reading function happens.

File Assumptions:

There are 2 assumptions made that the file is not empty, and the file is readable e.g. there are spaces between the words.

Change to make - Validated if the file exists and has white spaces included between the words, validation before being read need to be included.

OOP principles:

Linking into the code structure all the code is in the main program; there are no classes or objects beside that.

Change to make- Create a class that encapsulates Multiple smaller functions.

Output:

The program should, Read the sample text file, remove punctuation, convert all words to lowercase, count how many times each word appears, count the number of unique words while the outputs are functional its very basic, which it all does but to a very basic level.

Change to make - The output can be more user friendly and visually appealing, the outcome can be alphabetically sorted, and the out puts are more labeled and clearer.

Program Logic:

The program logic is derived from the tasked the program is meant to achieve when complied. The program has logic for reading lines, removing punctuation etc. which it all does but to a very basic level.

Change to make- Improvements can be made by the program being able to support larger files. This can be done by files being read line by line instead of compiling all to memory.

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