This quiz is designed to test your ability to refactor code using professional best practices. Working in pairs, you will refactor provided code by improving its readability, efficiency, and scalability. You will also apply the Software Development Life Cycle (SDLC), using structured phases to enhance the code. Each group will fork the repository, refactor the code, and submit a pull request with their improvements.
- Apply concepts from Unit 1: Data Storage and Control Flow:
- Writing variables and constants
- Arithmetic operators
- Input/output system
- Conditional operators
- Control structures
- Avoiding magic numbers
- Lists of data with arrays
- Basic SDLC principles
You must follow the SDLC process to refactor the code:
- Phase 1: Requirements Analysis – Understand the original code, identify its weaknesses, and define improvement requirements.
- Phase 2: Design – Plan how to improve the code structure, renaming variables, optimizing logic, and making it more efficient.
- Phase 3: Implementation – Refactor the code following your design plan, ensuring better readability and efficiency.
- Phase 4: Testing – Test the refactored code with multiple inputs to ensure correctness and improvements.
- Phase 5: Documentation & Maintenance – Write clear comments, and submit your final version, ensuring the code is easy to maintain.
-
Repository Forking:
- Fork the repository to create a copy in your GitHub account.
- Clone the repository to your local machine.
-
Analyze the Code:
- Carefully read the provided code.
- Identify magic numbers, unclear variable names, or inefficient logic.
-
Refactor the Code:
- Improve the variable names, replace magic numbers with constants, and optimize the control structures.
- Make sure to add comments explaining the logic and changes you made.
- Apply arrays where repetition of variables exists.
-
Test the Refactored Code:
- Run the program with different inputs to validate that the refactored code functions as expected.
- Ensure the program handles errors gracefully (e.g., invalid input, edge cases).
-
Submit Your Work:
- Once you complete the refactorization, push your changes to your forked repository.
- Create a pull request (PR) to the original repository, explaining the improvements you made and how you followed the SDLC approach.