I have got a relatively complex piece of logic, i called it OOP style for a few reasons:
-
It involves managing a piece of “configuration” for a particular system and rendering/updating that system in a react based UI
-
the configuration is comprised of a few main fields, let’s call them
actions
andresponses
. -
there are different types of actions and responses and each of them have different properties, so the ability and options available for configuration depends largely on what type of actions and responses are available.
-
this config is converted into reactflow’s nodes and edges, and the conversion is also based largely on the types of actions and responses available in the config
-
there are sibling components to reactflow so this object has to be a step above them and feed it’s data to reactflow and it’s siblings (and cause re rendering which is difficult when using class instances)
I should mention I use typescript because data integrity and typing is critical here, so having to use functions and immutable objects to manage all this has gotten very messy since there is a lot of type checks, switch statements to determine configuration fields and options and even switch statements to determine how the objects when modified are converted back to the final configuration object (using reducers).
I understand this is very theoretical but i can’t share more due to legal reasons, i will appreciate any guidance on if switching to OOP (for the benefit of inheritance and extendability) is the way to go.
I already tried that out on a different branch but ran into issues with managing rendering and rerendering, including the fact that react was designed in an event style pattern (events go up, data comes down)
PS: i am new to react and typescript, but fairly experienced in programming in general (started out in the early 2010s with java and c) so do let me know if i am missing some typescript or react concept that makes logic like this easier in a functional manner.
Also do let me know if more details are necessary, i will do my best to provide them 🙂