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

Refactor Hotel Management System Code for Improved Readability and Maintainability #50

Open
PritishDoc opened this issue Jul 9, 2024 · 0 comments

Comments

@PritishDoc
Copy link

Class Structure and Design:
The holder class should follow Java naming conventions (e.g., Holder instead of holder).
Encapsulation should be implemented to protect the data in classes like Singleroom, Doubleroom, and holder.

Code Duplication:
There is significant duplication in methods such as bookroom, deallocate, order, and bill. These methods should be refactored to reduce redundancy and improve maintainability.

Exception Handling:
The current exception handling is minimal and does not provide meaningful error messages or recovery options. More specific exceptions and error handling should be implemented.

Magic Numbers:
The use of magic numbers (e.g., room numbers in bookroom, deallocate, order, and bill methods) should be avoided. These should be replaced with constants or enumerations.
Input Validation:

Input validation is lacking in several areas, which could lead to runtime errors. Input validation should be added to ensure robustness.
Switch Cases:

The switch statements in CustDetails, bookroom, features, availability, and bill methods are extensive and can be simplified or refactored using more modern design patterns like the strategy pattern.
Serialization:

The serialization logic is embedded in the main class and the write class. Consider creating a separate utility class for handling serialization and deserialization.

Thread Safety:
Ensure that the code is thread-safe, especially with regard to the shared holder object.

  • Consider using modern Java features and design patterns to refactor the code. Adding unit tests would also be beneficial to ensure that the refactored code works as expected.
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