Skip to content

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

Merged
ramedina86 merged 7 commits intowriter:devfrom
FabienArcellier:refactor/design-proposal-for-component-tree
May 13, 2024
Merged

refact: proposal for a new design arround component tree#367
ramedina86 merged 7 commits intowriter:devfrom
FabienArcellier:refactor/design-proposal-for-component-tree

Conversation

@FabienArcellier
Copy link
Contributor

@FabienArcellier FabienArcellier commented Apr 1, 2024

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.

@FabienArcellier FabienArcellier force-pushed the refactor/design-proposal-for-component-tree branch from 38efd79 to cbd02ff Compare April 1, 2024 15:13
super().__init__(attach_root)
self.base_component_tree = base_component_tree
def __init__(self, trees: List[ComponentTreeFragment]):
assert len(trees) > 0, "Component tree must have at least one tree fragment"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily true for CMC trees, they can be empty if the user chooses to not create any CMCs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed trees to tree_branches. A tree can have 0 components but it must still have several branches, one for the bmc, one for the cmc and one for the smc

@FabienArcellier FabienArcellier force-pushed the refactor/design-proposal-for-component-tree branch from cbd02ff to 364b87a Compare April 6, 2024 12:38
@FabienArcellier FabienArcellier force-pushed the refactor/design-proposal-for-component-tree branch from 111fee7 to 6d3fbd4 Compare April 15, 2024 02:40
@ramedina86
Copy link
Collaborator

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:

  • Builder-managed
  • Code-managed

The other classification emerges from the specificity of the components:

  • Shared/base
  • Session-specific

Therefore, the combinations are:

  • Builder-managed base components
  • Code-managed base components
  • Builder-managed session-specific components
  • Code-managed session-specific components

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

  • Builder-managed base components: bmc
  • Code-managed base components: cmc
  • Code-managed session-specific components: session-cmc

@mmikita95 fyi, feel free to add to the conversation

@FabienArcellier
Copy link
Contributor Author

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
Copy link
Contributor

@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
Copy link
Collaborator

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

@mmikita95
Copy link
Contributor

mmikita95 commented Apr 15, 2024

My thought is

  • Builder-managed components (bmc)
  • Pre-Session code-managed components (pscmc)
  • In-Session code-managed components (iscmc)

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

@ramedina86
Copy link
Collaborator

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

  • bmc
  • initial_cmc
  • session_cmc

in line with state (initial_state, session_state).

@FabienArcellier FabienArcellier force-pushed the refactor/design-proposal-for-component-tree branch from 6d3fbd4 to f96e538 Compare April 24, 2024 16:42
FabienArcellier added a commit to FabienArcellier/writer-framework that referenced this pull request Apr 24, 2024
* rename different branch regards to ramiro comment (writer#367 (comment))
@FabienArcellier FabienArcellier force-pushed the refactor/design-proposal-for-component-tree branch from b72a85c to 0661ed8 Compare May 1, 2024 13:06
@ramedina86 ramedina86 merged commit cef4ee1 into writer:dev May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants