code review (resit)#12
Open
420sam wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
-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.