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

Solution #1427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #1427

wants to merge 1 commit into from

Conversation

tetiani
Copy link

@tetiani tetiani commented Oct 9, 2024

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on your code! I can see that you've put a lot of effort into it. However, there are a few areas that need improvement. The movie_session method could be better organized for readability and maintainability. Also, consider using list comprehension for efficiency and ensure to add docstrings to your functions. Keep up the good work! 😊👍

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

app/cinema/bar.py Show resolved Hide resolved
Comment on lines +9 to +19
def movie_session(
self,
movie_name: str,
customers: list["Customer"],
cleaning_staff: "Cleaner"
) -> None:
print(f'"{movie_name}" started in hall number {self.number}.')
for customer in customers:
customer.watch_movie(movie_name)
print(f'"{movie_name}" ended.')
cleaning_staff.clean_hall(self.number)

Choose a reason for hiding this comment

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

The movie_session method is doing too much. It's not only starting and ending the movie session but also managing the customers watching the movie and the cleaning of the hall. This violates the Single Responsibility Principle and makes the method harder to read and maintain. Consider breaking this method into smaller methods, each with a single responsibility. For example, you could have separate methods for starting the movie, ending the movie, managing the customers, and cleaning the hall.

Comment on lines +7 to +12
def cinema_visit(
customers: list,
hall_number: int,
cleaner: str,
movie: str
) -> None:

Choose a reason for hiding this comment

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

The function cinema_visit could benefit from a docstring that describes its purpose, parameters, and return value. This is a good practice and it will make your code easier to understand for other developers.

Comment on lines +13 to +15
cleaner_obj = Cleaner(cleaner)
hall = CinemaHall(hall_number)
cinema_bar = CinemaBar()

Choose a reason for hiding this comment

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

The instantiation of Cleaner, CinemaHall, and CinemaBar objects inside the cinema_visit function might limit the reusability of this function. If you want to use this function with different instances of these classes, you would have to modify the function. A better approach might be to pass these objects as parameters to the function.

Comment on lines +18 to +24
for customer in customers:
customer_obj = Customer(customer["name"], customer["food"])
cinema_bar.sell_product(
product=customer_obj.food,
customer=customer_obj
)
customer_objs.append(customer_obj)

Choose a reason for hiding this comment

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

Here you are creating a Customer object for each customer in the customers list, and then appending it to the customer_objs list. This operation could be more efficiently done using a list comprehension. This would make your code more concise and more Pythonic.

Comment on lines +26 to +30
hall.movie_session(
movie_name=movie,
customers=customer_objs,
cleaning_staff=cleaner_obj
)

Choose a reason for hiding this comment

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

The function call hall.movie_session is a bit hard to read due to the number of arguments and their formatting. It could be improved by using one line per argument. This would increase the readability of your code.

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