Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Code Reusability / DRY (Don't Repeat Yourself) #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LyubomirT
Copy link

This pull request refactors the code execution functions for supported languages (Python, Java, C, and C++) to eliminate code duplication and improve maintainability. The previous version of the script had separate functions for each language, resulting in repetitive code blocks. In this update, we introduce a dictionary, SUPPORTED_LANGS, which maps language names to corresponding execution functions. Each execution function now dynamically generates a temporary file for the code, compiles (if necessary), and runs it with the provided arguments.

To support more languages in the given compiler, you can extend the list of supported languages in the SUPPORTED_LANGS dictionary. For each language, you need to specify a list of steps to compile and run the code. Each step is represented by a dictionary with the following keys:

  • command: The command to execute.
  • ext: The file extension of the code file.
  • USE_ARGS: A boolean flag indicating whether to use the arguments parameter in the command.

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