lundi 20 mars 2023

Selecting an architecture for objects of the same family with different function variants and variable inputs

I have many types of objects (screws, dowels, and many more) of the same family (fastener) who all have a function called 'geometry_requirements'. This function always takes a few common arguments and a few different arguments based on the object type.

One of the requirements is that the geometry requirements need to be stored in a database, making it very lenghty and 'empty' due to the differences between fasteners. Thus, the main challenges are making the construction of the tables for the database efficient and the overall approach able to accomodate for various conditions and various inputs.

Question: Are design patterns, or structures, or any solutions to this that I can explore and compare (to the solution below) please?

Initial approach:

My initial approach was to construct a database with only essential information to limit the length and then implement a Strategy Pattern to accommodate for special considerations.

class GeometryRequirements()

  • mapping of strategies, select the right one and perform operations

class GeometryStrategy

  • abstract class

class ObjStrategy(GeometryStrategy)

  • one strategy class per fastener type
  • handles input validation, conditions and query to database

Aucun commentaire:

Enregistrer un commentaire