I'm developing a reservation (equipment, meeting rooms, etc...) system here at at work and am interested in some feedback eventhough I'm pretty 80% convinced that the design in my head will work fine.
Anyway, this reservation system is something that will most likely be used amongst many different groups. Each of these groups having their own bits fo stuff to loan out and their own rules or policies to govern this. Now there is no way to write one bit of code that is going to work for all of the different groups. It's obvious that I need a rules or policy basd algo. Here is what I've come up with.
1) A table that stores the rules based on the groups they belong too and the type of rule it is (type is enum).
2) Each line/rule in the table will have a rule_processor field. This field is a string representing a call back function.
Keeping the above in mind, when a reservation is in the process of finalization (and potentially at other steps as well), the rules table is interogated for matches. If a match is found, then the corresponding call back function (or method) gets a crack at the submitted reservation data and can manipulate it as needed.
In this way, changing any of the specifics for any of the groups is a breeze over time.
BUT KNOWING ME, I'm bound to have forgotten something.
Cheers,
BDKR