OOP: too many interactions between different classes
Mostrar comentarios más antiguos
I am currently programming (OOP) a model for a separation process similar to column chromatography. As the different physical phenomenon that occur during the separation process can be described by various correlations, I want to keep the model as flexible as possible, so one can easily switch between those approaches. However, the code must not take too much time to run, of course. Hereafter, I will try to give a quick overview of how I structured the model:
Class Process: This class contains properties with information about the process like geometry, flow rates, feed composition etc. and properties that specify what approaches for the mathematical description of the physical phenomenon like fluid dynamics or adsorption kinetics are used. It is also the class where most of the calculations take place.
Superclasses and subclasses for physical phenomenon: For each phenomenon I created its own superclass. Thus, every specific approach is a subclass of the corresponding superclass (eg. Superclass: adsorption - Subclass: Langmuir). I decided to program it this way to make sure that even by using another approach the code of the class Process does not have to be changed, but only the information in its properties.
Class Component: As the components in the feed have different physical properties, I created a class that creates an object and, depending on the component name, stores the specific information as compProp as a property.
Aim of this model is showing how the concentration of the different components varies with location and time and thus requires solving a system of differential equations. The class Process includes a method which creates the system (via a nested function) and solves it afterwards.
The part of creating that system of differential equations is the part my question refers to: As the equations depend on which approach for the particular physical phenomenon is used, the class Process has to call up at least one of the subclasses for each row of the equation system to fill in the specific correlations. Sometimes it is necessary that a subclass again has to call up another subclass. Furthermore, every subclass needs the whole object of the class Process as input, as the geometrical information or component specific constants they rely on, are stored in its properties.
Apparently, the structure is quite complicated, but I did not know another way to keep model as flexible as possible. So here is my question: Is there an obvious alternative way for problems like this that I may not know (I am new to programming with matlab)? Or is there a rule of thumb how many interactions and classes are too many?
I know it is a quite rough sum up of the whole project, but nevertheless maybe someone who is more familiar with matlab has got a solution for this problem that I just missed.
Thank you in advance!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Numerical Integration and Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!