C#C
C#3y ago
LazyGuard

❔ How to design this code ?

Hi folks, I am having some troubles coming up with a design for the following problem.
I have a Product object that have a several properties (e.g. category (a string), dangerous (a boolean), type (enum), length(int), height(int), weight(int) etc.)
There is a set of rule that allows to set the value of some properties based on conditions on other properties. For example : Set the Type property to "Big" when Length >2 and Weight >15. Another example : "Set the Dangerous to true when Category == fireworks.
Those rule must not be harcoded in the code, because our users want to have the possibility to add such rules on their own.
Does anyone have an idea on how to do this ? Some of my pain point are :
  • How to model a rule in a nosql database ?
  • How to apply it seamlessly on the Product objects etc.
Was this page helpful?