writer / writer-framework

No-code in the front, Python in the back. An open-source framework for creating data apps.
https://dev.writer.com/framework/introduction
Apache License 2.0
1.3k stars 73 forks source link

refact: proposal for a new design arround component tree #367

Closed FabienArcellier closed 4 months ago

FabienArcellier commented 5 months ago

This is a refactoring proposal to make the notion of component tree simpler. This refactoring removes the 3 distinct classes that inherit from each other to represent the 3 trees. It removes cascading inheritance and method overloading.

There is a single class ComponentTree class that can combine fragments. One fragment for BMC, one for CMC, one for SMC. A fragment can be frozen to lock its contents. Fragments are an instance of the same ComponentTreeFragment class.

The application contains 2 tree construction methods. build_base_component_tree which builds the tree the application needs upon loading with a fragment for BMCs and CMCs. build_session_component_tree builds a tree dedicated to the user session with 3 fragments, one fragment for SMCs, one for CMCs and a frozen fragment for BMCs. The fragments are copied to separate them from the base representation.

I added in the tests, 2 distinct contexts, one to represent a ui manager when streamsync application is loading and one to represent a ui manager in an event handler.

ramedina86 commented 5 months ago

This is a step in the right direction. However, I'd like to change the nomenclature "smc" as I don't think it's reflective of what we're doing.

Manage should be interpreted in the sense of enabling the user to create, delete, etc. Not from an internal perspective. Two categories emerge:

The other classification emerges from the specificity of the components:

Therefore, the combinations are:

There are currently no plans to have builder-managed session-specific components. For simplicity, we can adopt the following:

@mmikita95 fyi, feel free to add to the conversation

FabienArcellier commented 5 months ago

This is a step in the right direction. However, I'd like to change the nomenclature "smc" as I don't think it's reflective of what we're doing.

That's sound interesting, I will take a look at the change involved.

mmikita95 commented 5 months ago

@ramedina86 great breakdown, thank you!

One thing I would probably adjust is to shift focus on "session CMCs" as "main CMCs" (i.e., use names like "pre-session CMCs vs session CMCs or in-session CMCs"), because in my opinion, while "pre-session CMCs" are expected to be used more widely, technically the session context is the last point that collects all components into a "render package", and one can view "pre-session CMCs" as "copies made for the session". Therefore, to better reflect this technicality, I'd suggest this naming convention. Sorry if this is turning out to be too confusing 😅

ramedina86 commented 5 months ago

Excellent point @mmikita95 , glad I tagged you. With this in mind, what classification (short names) would you go for?

mmikita95 commented 5 months ago

My thought is

but I'm slightly dubious on that, as these 5-letter acronyms look dangerously "too much".

ramedina86 commented 5 months ago

iscmc sounds too much like a boolean. The pre is slightly confusing to me. How about:

in line with state (initial_state, session_state).