So i'm in a situation, where i would like to have a database of objects that contain classes to run. It would look something like:
id | Description | pricingClass
1 | "static pricing" | staticDeliveryPrice.class
2 | "Dynamic pricing" | dynamicDeliveryPrice.class
The purpose of this is to allow flexibility in my coding. My line of thought is, this would allow for multiple ways of determining how to figure out a price of a deliveryMethod.
The problem I'm worried about is, is reflection bad to use in this scenario? Is there a better way to do it? Is it following the solid principles.(I would say yes, but part of me disagree).
You're describing a plugin-based architecture. Do you really need this kind of flexibility ? It's usually necessary when:
Otherwise, it's completely overkill. You have full control on what goes in your product, so you can simply rely on good old polymorphism to isolate the different implementations of your feature.
Also, it's not a very good thing to put business logic in the database: you mix concerns, you create strong coupling (suddenly renaming classes will become annoying!), and of course, it's harder to reason about what happens in your code by just looking at it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With