Code Review#15
Open
Tiwi71 wants to merge 1 commit 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.
Code does what it should, which is nice. Would be helpful if variables were more clearly named and commenting was utilised so that someone viewing the code could gain an idea on what it does more easily, rather than having to parse and understand each line.
Linguistic decisions could be improved. 'gimmefile' is a potentially confusing instruction, potentially leading the user to just write 'x.txt' which would not work. 'Please enter the file directory' would be a clearer instruction. 'Done' is an acceptable way of explaining to the user that the file had been read and ran through the program, but something like 'File read and parsed' would be clearer. 'Uniquez' could be replaced with 'number of unique words:' for better user understanding.
The error handling of the code could also be improved. If the user inputs something that isn't a file directory, or simply presses 'enter' without typing anything, an exception error occurs and the program crashes. Error handling components would be helpful, with a line to the user about the input not being valid.
More options would be also be useful. Whilst the user may want the words to be listed in file order, having options to order them by frequency or alphabetically would be convenient.
When you click 'Copy as Path' for the txt file in File Explorer, Windows automatically encases it with "", so having a few lines that remove those would be useful to reduce user difficulties.
Even if the program succeeds, reads the text file and parses it correctly, it would be useful if it would loop and prompt the user if it wants to run another file. That way, if the user wishes to see the word frequency of multiple files, they don't have to start up the program every time.
More OOP principles could also be applied. Whilst the code doesn't do a lot, so all of it being inside 'static void Main' is potentially acceptable, it poses issues if you wish to expand the program to analyse the file in different ways and produce different outputs. Having different functions, such as the dictionary and trimming lines/whitespace, in their own classes which Main then calls upon would stop Program.cs from becoming bloated and difficult to navigate. A polymorphic function for converting different text file contents into the same format for the program to use would be also be helpful, as the program only works for .txt files.
Overall a decent code,. It could just do with more readability, error handling, and easy to implement user options. If you want to expand it to do more, please apply the OOP principles I've described!