mardi 14 avril 2020

Design Pattern for Meta Abstraction Layer

Currently I am struggling around to find suitable software engineering design patterns which could help me keeping my code base clean, maintainable and testable. To give you an overview what I want to achieve take this database diagram for reference.

Brief overview on the database structure

As you can see I've got quite a simple database structure with only a product table, a corresponding meta table which should hold all the nesseccary information for the specific product and a product category table.

Now my goal is to find a way to keep the database structure as simple as possible which in this case gives me the opportunity to add and control information for each product on the application side. For this I simply need to add (or remove) certain key/value pairs to the meta-table.

My base structure for every product is the same. For example it belongs to a set of categories, it has information for pricing and some other meta information which must be set on each individual product. Just ignore the cardinality for know because they are not yet correct on that screen.

Each category needs specific additional information for the product. A product which belongs to category "non-digital" for example needs additional information for the current stock. A "digital" product however does not need nor should have this information but it has fixed information for downloads e.g.

I don't know how to describe this correctly but I want to build up a kind of virtual "Guard"-Layer on top of my products or more abstract on top of my object<->meta construction as I have more than one table structures which follow the same design (A concrete object table and an associated meta table).

I was thinking of somehow to use the adapter pattern to extend the set of mandatory meta-keys or to use the factory pattern but that still does not really get the job done to setup a "virtual layer". It seems to rather overcomplicate the whole thing.

I am sure there is a sophisticated solution for my use-case which I don't know yet but hopefully someone else does. I could be that I am completely off track.

Aucun commentaire:

Enregistrer un commentaire