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

Box Class Implementation #141

Open
Swapnilden opened this issue Jul 27, 2024 · 0 comments
Open

Box Class Implementation #141

Swapnilden opened this issue Jul 27, 2024 · 0 comments

Comments

@Swapnilden
Copy link

Summary

The initial implementation of the Box class contains several bugs and areas for improvement. This report identifies the issues and proposes a solution to address them.

Description of Issues

  1. Side Counting Bug:
  • Issue: The sides attribute is incremented each time a side is set, regardless of whether the side was previously unset. This can lead to incorrect counting if a side is set multiple times.

  • Impact: Incorrectly incrementing sides could prematurely mark a box as complete (with all four sides set) when it is not.

  1. Repetitive Code in Setters:
  • Issue: The setters for _top, _bottom, _left, and _right are repetitive and contain similar logic.

  • Impact: This makes the code harder to maintain and increases the likelihood of bugs.

Proposed Changes

  1. Fix Side Counting:
  • Implement a check to ensure that sides is only incremented if the side was previously unset.
  1. Refactor Setters:
  • Use a private method _set_side to handle the logic for setting sides, reducing code repetition and improving maintainability.
  1. Additional Enhancements:
  • Add type hints and docstrings for better code readability and maintainability.

  • Implement a method to get neighboring boxes, which can be useful for grid-based logic.

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

No branches or pull requests

1 participant