educative.io

A few questions about the design

Why does parking floor have a different map for each vehicle type?
Each code is also doing a switch of each vehicle type. It seems an obvious code smell to me. I’d use inheritance and have a single map of a generic “Vehicle”

Is there a reason why the ParkingDisplayBoard is not an observer subscribed to the parking spots?

Why does the parking spot have a ‘free’ variable? When we set and unset ‘vehicle’ we also set free. We can just check if (vehicle == null) to assess if it’s free

Why do we have a separate class “ParkingAttendantPortal”. Can the ParkingAttendant have those responsibilities?

I’ll stop here. I’d be grateful if someone can clarify. Thank you!

@Design_Gurus

Hi @Pierluigi_Urru
We are very glad to see the keen interest that you have noticed in the overall design of our approach.
The given solution is just for the implementation purpose, there are several other ways to implement the same problem as you have mentioned above. So you can use your own design as well by just taking the idea from our given solution. Your feedback is much appreciated.

Thanks for reaching out to us!