Code Smell Removal Documentation - UQcsse3200/2023-studio-2 GitHub Wiki
Code Smell Removal Documentation
Introduction
This document outlines the steps and strategies employed to reduce code smells in our game project from 1.4k lines to 1.2k lines by 17th October 2023. The primary focus will be on removing unused code, refactoring existing code, and reducing cognitive complexity.
Tasks achieved
- Reduced the total line count from 1.4k to 1.2k lines.
- Removed unused code.
- Refactored code for improved readability and maintainability.
- Reduced cognitive complexity, making the code more understandable.
Initial number of Codesmells present
200 Codesmells removed till October 17th 2023
Strategies Taken
1. Code Analysis
Before starting the removal of code smells, we conducted a thorough analysis of the codebase to identify areas where code can be reduced or refactored. We'll use static code analysis tools and manual code reviews to locate potential issues.
2. Identifying Unused Code
a. Search for Dead Code
We identified and removed dead or unused code segments. This includes variables, functions, and modules that are no longer necessary for the game.
b. Unused Dependencies
We also analysed dependencies to ensure we're not importing unused libraries or modules.
3. Refactoring
a. Code Duplication
Identified and eliminated code duplication, as it contributes to unnecessary bloat. Created reusable functions or classes where necessary.
b. Simplify Conditionals
Simplify complex if-else statements or switch cases to make the code more readable.
c. Modularization
Broke down large functions or methods into smaller, more focused ones, improving code organisation.
4. Reducing Cognitive Complexity
a. Naming Conventions
Ensured that variable and function names are self-explanatory and follow consistent naming conventions.
b. Commenting
Improved code comments to provide clear explanations and context for complex logic.
c. Spaghetti Code
Identified and reorganized spaghetti code (deeply nested or interdependent code) to make it more linear and readable.