No meaningful public members

Hi! Trying to understand the Parking Lot design. Some classes don’t have public members at all, for example Person or Address. Others don’t have meaningful public members, for example ParkingRate has only one public member declared as void calculate(); which doesn’t make sense to me as the method doesn’t have parameters and returns nothing. What is the purpose of such classes? They look unusable to me.

Course: Grokking the Low Level Design Interview Using OOD Principles - Learn Interactively
Lesson: Code for the Parking Lot - Grokking the Low Level Design Interview Using OOD Principles

HI @Sergei !!
In the code, some classes like Person or Address don’t have any public members, these classes might be used to represent personal information associated with the user accounts in the parking lot system. They could contain private fields for attributes like name, email, phone number, etc., along with public getter and setter methods to access and modify these attributes. Similarly, the Address class might store details like street, city, and zip code. These classes can be utilized within the Account class to store and manage user-related information. and the ParkingRate class has a void method named calculate() without parameters or a return value.

Regarding the ParkingRate class, the calculate() method could be responsible for calculating the parking fee based on certain criteria such as the duration of parking and parking rate. The implementation of this method is more complex and involves internal calculations and interactions with other classes.
I hope it helps. Happy Learning :blush:

1 Like