Recall & Review
beginner
What is an enum and why is it useful in system design?
An enum (short for enumeration) is a special data type that lets you define a set of named constants. It helps make code clearer and safer by restricting values to a fixed set, like types of vehicles or parking spots.
Click to reveal answer
beginner
Give an example of how VehicleType enum might be defined.
VehicleType enum could include values like CAR, BIKE, TRUCK. This helps the system know exactly what types of vehicles it can handle without errors.
Click to reveal answer
intermediate
Why use SpotType enum in a parking system?
SpotType enum defines different parking spot categories like COMPACT, LARGE, HANDICAPPED. It helps assign the right spot to the right vehicle type and manage space efficiently.
Click to reveal answer
intermediate
How do enums improve code maintainability?
Enums centralize the allowed values, so if you need to add or change types, you update in one place. This reduces bugs and makes the system easier to understand and extend.
Click to reveal answer
advanced
What could go wrong if enums are not used for VehicleType or SpotType?
Without enums, invalid or inconsistent values might be used, causing errors or wrong assignments. For example, a BIKE might be assigned a LARGE spot meant for trucks, wasting space.
Click to reveal answer
What does an enum represent in system design?
✗ Incorrect
Enums define a fixed set of named values to restrict possible inputs.
Which of these is a valid VehicleType enum value?
✗ Incorrect
CAR is a vehicle type; COMPACT, HANDICAPPED, LARGE are spot types.
Why is SpotType enum important in parking systems?
✗ Incorrect
SpotType helps categorize spots like COMPACT or HANDICAPPED.
What is a risk of not using enums for VehicleType?
✗ Incorrect
Without enums, invalid or inconsistent vehicle types can cause errors.
How do enums help maintainability?
✗ Incorrect
Enums centralize allowed values, making updates easier and safer.
Explain how enums like VehicleType and SpotType improve a parking system design.
Think about how fixed categories help avoid mistakes.
You got /3 concepts.
Describe potential problems if enums are not used for vehicle and spot types in a parking system.
Consider what happens if any string or number is allowed.
You got /3 concepts.
