how should I design Objects around this business requirement?
- by brainydexter
This is the business requirement:
"
A Holiday Package (e.g. New York NY Holiday Package) can be offered in different ways based on the Origin city:
From New Delhi to NY
From Bombay to NY
NY itself ( Land package )
(Bold implies default selection)
a. and b. User can fly from either New Delhi or Bombay to NY.
c. NY is a Land package, where a user can reach NY by himself and is a standalone holidayPackage.
"
Let's say I have a class that represents HolidayPackage, Destination (aka City).
public class HolidayPackage{
Destination holidayCity;
ArrayList<BaseHolidayPackageVariant> variants;
BaseHolidayPackageVariant defaultVariant;
}
public abstract class BaseHolidayPackageVariant {
private Integer variantId;
private HolidayPackage holidayPackage;
private String holidayPackageType;
}
public class LandHolidayPackageVariant extends BaseHolidayPackageVariant{
}
public class FlightHolidayPackageVariant extends BaseHolidayPackageVariant{
private Destination originCity;
}
What data structure/objects should I design to support:
options
a default within those options
Sidenote: A HolidayPackage can also be offered in different ways based on Hotel selections. I'd like to follow a design which I can leverage to support that use case in the future.
This is the backend design I have in mind.