From accbf7a87439f466045bc497346d625b55130c75 Mon Sep 17 00:00:00 2001 From: Jas-mine0 Date: Sun, 27 Jul 2025 14:19:30 +0100 Subject: [PATCH] Add files via upload Naming issues: There are no comments in the code which makes it difficult to know what is going on. "Console.WriteLine("gimmiefile");" is not a good naming convention as it is not memorable. "var z", "var q", "var s", "var t", "var w" "foreach (var e in a)", "int j", are also bad naming conventions as they do not explain what the varaible is and it will be confusing when you go back to the code and try to do more programming, as you won't know what the stand for or what they do. Code Structure issues: Code has not been put into different classes, which makes the code look clunky and hard to read. Code has not been split up into different files and the code violates the single responsibility principle, by not doing so the code is more difficult to understand. Error Handling issues: The code does not check if the file exists, which means that the program will crash if the file does not exist. No exception handling for the I/O operations on the file. No validation of user input (examples: empty strings, invalid paths) File Assumption issue: Assumes file exists and that it can be read. OOP Principle issues: No encapsulation is used, all of the logic is exposed in the main method. No abstraction has been used. Output issues: No sorting of results and poor formatting. Program Logic issue: No input validation or sanitization. Naming suggestions: Add comments to the code so it is more understandable, readable, and maintainable. The use of comments will help you understand your code when you go back to it later, in addition to helping other people understand what is going on with your code when they look at it. Change "Console.WriteLine("gimmiefile");" to be something more memorable. This will help as you will know what the code is meant to do if it is changed to be something more memorable/descriptive. Change "var z", "var q", "var s", "var t", "var w" "foreach (var e in a)", "int j" to something more memorable. This will help you when you go back to your code as you will then know what each thing stands for. Code Structure suggestions: Put the code into different classes, this will make the code less clunky and easier to read. Split the code into different files and ensure the code does not violate the single responsibility principle. Putting the code into different files will make the code more maintainable. Error Handling suggestions: Add error handling and check to see if the file exists. If it does not exist then ensure that the program ends gracefully. Ensure there is exception handling for the I/O operations on the file. This will ensure that there are no errors regarding exceptions. Validate user input to ensure that the input is what you expect from the user. This will ensure that whatever is input will not cause the program to crash. File Assumption suggestion: Check if the file exists and that it can be read. If it does not exist or cannot be read tell the user that it cannot be found or read. OOP Principles suggestions: Make use of encapsulation to avoid code being altered accidentally. Make use of abstraction. Output suggestion: Sort the results. Examples: sort by frequency, alphabetically, or length. Program Logic suggestion: Make use of input validation to ensure the user is giving valid inputs.