Imagine your customer want's to have a possibility to add new property (e.g. color) to product in their eshop in their CMS.
Instead of having properties as fields:
class Car extends Product {
protected String type;
protected int seats;
}
You would probably end up doing something like:
class Product {
protected String productName;
protected Map<String, Property> properties;
}
class Property {
protected String name;
protected String value;
}
That is, creating own type system on top of existing one. It feels to me like this could be seen as creating domain specific langauge, or couldn't?
Is this approach a known design pattern? Would you solve the problem differently? I know there are languages where I can add a field in runtime, but what about database? Would you rather add/alter columns or used someting as shown above?
Thank you for your time :).