Skip to content

Assignment1 Joanne Lim Zi Xuan#2

Open
Joanne1228-coder wants to merge 4 commits intodevfrom
assignment1_JoanneLimZiXuan
Open

Assignment1 Joanne Lim Zi Xuan#2
Joanne1228-coder wants to merge 4 commits intodevfrom
assignment1_JoanneLimZiXuan

Conversation

@Joanne1228-coder
Copy link
Collaborator

o The addressed issue
The original gen_requirements_all.py script for dependency management had several issues identified:

  1. The functions for mixed concerns, including parsing, validation, IO, diffing, and generation in a single script, are
    disorganised.
  2. Code duplication across the normalise_package_name function.
  3. Hidden bugs, such as:
    a) Sorting operations that did not actually modify the underlying dictionary.
    b) Recursive requirement gathering without proper cycle detection.
  4. Low readability due to lack of structure, comments, and cohesive abstraction.
    These problems increased technical debt and made modifications risky.

o Details of the reengineering task

  1. Rearranged and grouped the functions under similar aspects of requirements.
  2. Added more detailed docstrings to the function and inline comments for each section.
  3. Removed the duplicated code across the function by replacing it with a reference. (Code line 283 - 297)
  4. Fixed the dictionary-sorting bug in gather_modules(). Initially, the sorted list was stored in the "value" variable, which is
    local and temporal and does not affect the dictionary. (Code line 443 - 444)
  5. Implemented proper cycle detection in recursive requirement collection to avoid infinite loops. (Code line 371)

o The reengineering strategy used is rework, inducing the re-code type of changes to the implementation level
Involving:

  1. Reverse engineering: The original script was analysed to understand the dependency flow, invocation paths, and impacts of
    alteration, fixed output formats and the whole logic distributed across the code blocks.
  2. Behaviour-Preserving Transformation: The requirements, constraints and output formats are preserved after the refactor,
    ensuring the original runtime output will be obtained.
  3. Structural Reorganisation: Rearranged the existing code blocks by grouping them for each step of the
    dependency/requirement file generation.

o Impact of the changes

  1. Improve readability and maintainability of the code as they are more readable, modular and better documented.
  2. The new contributors can understand the script much faster.
  3. The previous silent sorting and recursion bugs are eliminated.
  4. Adding new requirement groups is now less error-prone.
  5. The functionality of the program remained unchanged.

Copy link
Collaborator

@suhadaudd11 suhadaudd11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proceed

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.

2 participants