We have a class
Vehicle, this class contains some properties to define the object such as a
A car (vehicle) also has options, these days a lot of options.
My idea is to create a separate class called
Options and list the needed options that I require as a Boolean value, then use
false to determine if the vehicle has that option or not.
Would this be considered a good idea or a lazy idea?
Should I even bother making a separate class for this or should I simply put all this info in the vehicle class.
Not just from a design point of view but also looking at the database to store this information.
There is no intention of making the vehicle class a base class for multiple other classes.
My alternative would simply be an array of string value's. This would be less restrictive when it come to adding in new options and maybe even better in terms of data usage in a database (I think).
- Booleans: every option will need a true or a false value.
- Strings: there will be something or there will be nothing at all to store.
Ideas besides the 2 that I posted are also welcome.
Vehicleclass sounds like exactly what you need. Given what you say, I don't see any reason to overcomplicate things by having a separate class for boolean properties or create arrays or some other special data structure for them.
Flagsenumeration for this purpose.