how should I design Objects around this business requirement?
Posted
by
brainydexter
on Programmers
See other posts from Programmers
or by brainydexter
Published on 2012-03-22T10:50:42Z
Indexed on
2012/03/22
17:42 UTC
Read the original article
Hit count: 273
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.
© Programmers or respective owner