Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

[Suggestion] Improve code readability with helper functions #16

Open
gptgit opened this issue Jul 1, 2023 · 2 comments
Open

[Suggestion] Improve code readability with helper functions #16

gptgit opened this issue Jul 1, 2023 · 2 comments
Assignees
Labels
suggestion Give me your suggestions, NOW!

Comments

@gptgit
Copy link

gptgit commented Jul 1, 2023

The code could be made more readable and modular by using helper functions for certain repetitive tasks. By encapsulating these tasks into functions, the main code can become more concise and easier to understand.

Implementation Details:

  1. Create a helper function load_chars_file to handle the loading of the chars.txt file. This function should return the contents of the file as a string.
  2. Create a helper function load_translation_file to handle the loading of translation files based on the user's Windows language. This function should take the language code as a parameter and return the parsed JSON data.
  3. Refactor the code in the main section to use the helper functions. Instead of manually opening and reading the chars.txt file, call the load_chars_file function. Similarly, instead of manually opening and parsing the translation file, call the load_translation_file function with the appropriate language code.
  4. Update the error handling in the main section to properly handle file not found errors and raise the appropriate exceptions.

Expected Benefits:

  • Improved code readability and maintainability.
  • Modular code structure with reusable helper functions.
  • Better error handling and exception raising.

Additional Context:
The proposed changes will make the code more organized and easier to maintain, especially when dealing with file operations and language translations. By encapsulating these tasks into functions, it will also make it easier to modify or extend these functionalities in the future.

@KwiatekMiki KwiatekMiki self-assigned this Jul 3, 2023
@KwiatekMiki KwiatekMiki added the suggestion Give me your suggestions, NOW! label Jul 3, 2023
@KwiatekMiki
Copy link
Owner

Ok!

@CuriousDog81
Copy link

Do something, bruh.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
suggestion Give me your suggestions, NOW!
Projects
None yet
Development

No branches or pull requests

3 participants