shouryaj98 / Hotel-Management-Project-Java

It is a Hotel Management tool which can be used to manage activites like storing customer details, booking rooms of four different types, ordering food for particular rooms, unbooking rooms and showing the bill.
MIT License
346 stars 435 forks source link

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

Open PritishDoc opened 4 months ago

PritishDoc commented 4 months ago

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.