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

Solid Principles compliance #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dsantistevan
Copy link

@dsantistevan dsantistevan commented Jul 13, 2020

#3 The class Guest that has the variables held before by a room has been added to the project, also some changes were made to the Project.java class in order to comply with it. The class Guest has the following structure:

public class Guest implements Serializable{
	String name;
    String contact;
    String gender;

The attributes kept default access so the program can access them like before.

#5 The fixes to the OCP principle were made by creating an abstract class Room that has an ArrayList of Guest objects and can add up to maxCapacity int variable amount of elements. SingleRoom has a maxCapacity of 1 and DoubleRoom a max capacity of 2. Also, the code was adjusted to comply with these changes.
The class Room has the following structure and method addGuest():

abstract class Room implements Serializable{
	ArrayList<Guest> guests=new ArrayList<>();
	int maxCapacity;
	ArrayList<Food> food =new ArrayList<>();
	
	void addGuest(Guest g) {
		if(g!=null && guests.size()<maxCapacity)
			guests.add(g);
		else if(g!=null)
			throw new NotAvailable();
		
	}
}

@dsantistevan
Copy link
Author

dsantistevan commented Jul 13, 2020

#6 Added classes FoodItem and FoodList, in order to comply with Open Closed Principle of SOLID design.
Now to extend the amount of items it's just needed to add them at the initiateFood method, it could also read from a file, but now it is only necessary to modify initiateFood.

        static void initiateFood() {
		foodList.add(new FoodItem(50,1));
		foodList.add(new FoodItem(60,2));
		foodList.add(new FoodItem(70,3));
		foodList.add(new FoodItem(30,4));
	}

@dsantistevan dsantistevan changed the title Added Guest class and adjusted code to comply with it Solid Principles compliance Jul 13, 2020
@PrajaktaBendreBito
Copy link

PrajaktaBendreBito commented Oct 25, 2024

Code Review Agent Run #2aa38a

High-level Feedback

The code demonstrates commendable efforts in restructuring and improving the hotel management system. Key strengths include the introduction of abstraction and better organization of classes. However, there are critical areas requiring attention, particularly in resource management and exception handling. Prioritize addressing the potential resource leak in file operations and correct the serialization issue to prevent performance degradation. Additionally, optimize the addGuest method and reconsider the exception hierarchy for NotAvailable. Implementing these changes will significantly enhance the system's robustness and efficiency. Keep up the good work in refining the architecture, and consider adding unit tests to ensure the reliability of these improvements.

Actionable Issues

📄 Project.java
Issues: Total - 4, High importance - 4
Line 52-52 🔴 High importance - 1   
Line 74-74 🔴 High importance - 1   
Line 503-503 🔴 High importance - 1   
Line 525-525 🔴 High importance - 1   
📄 Guest.java
Issues: Total - 1, High importance - 1
Line 11-11 🔴 High importance - 1   

AI Code Review powered by Bito Logo

Note: Introducing Bito’s AI Code Review Agent in your IDE. Get on-demand feedback with context as you code in JetBrains or Visual Studio Code. Catch issues early, improve code quality, ship faster — all before you get to PR. Learn more

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