In a parking lot system, VehicleType and SpotType enums are used. What is the main purpose of using enums here?
Think about how enums help avoid errors by limiting options.
Enums define fixed sets of constants, ensuring only valid vehicle and spot types are used, improving code safety and readability.
Which design best represents the relationship between VehicleType and SpotType enums in a parking lot system?
Consider how the system knows which vehicle fits which spot.
Mapping VehicleType to compatible SpotTypes allows the system to validate if a vehicle can park in a given spot type.
When adding new vehicle and spot types frequently, what is the best approach to keep the enum usage scalable and maintainable?
Think about how to avoid frequent code changes for new types.
Using extension points or configs allows enums to be flexible while preserving type safety and maintainability.
What is a key tradeoff when choosing between using enums or a database table to represent SpotType in a parking system?
Consider flexibility versus performance and safety.
Enums provide fixed, fast, and safe values at compile time; databases allow dynamic changes but with overhead and potential errors.
A parking system uses enums for VehicleType and SpotType. Given 3 VehicleTypes and 4 SpotTypes, with each VehicleType compatible with 2 SpotTypes, estimate the minimum number of spot instances needed to support 100 vehicles simultaneously, assuming uniform distribution and no sharing.
Think about how many spots are needed if each vehicle must have a compatible spot without sharing.
To support 100 vehicles simultaneously with no sharing, the minimum number of spot instances required is 100—one per vehicle. Enums ensure compatibility between vehicles and spots but do not increase the total number of spots needed beyond the vehicle count.
