Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: technical debt with data transformation #7918

Open
anisometropie opened this issue Jul 2, 2024 · 2 comments
Open

front: technical debt with data transformation #7918

anisometropie opened this issue Jul 2, 2024 · 2 comments
Assignees
Labels
area:front Work on Standard OSRD Interface modules kind:refacto-task Task related to Refactorization Epic

Comments

@anisometropie
Copy link
Contributor

anisometropie commented Jul 2, 2024

Description and goal

in ManageTrainScheduleV2, some major transformation on pathfinding data is delegated to sub components TypeAndPathV2.

launchPathFinding has much more responsibility than a mere (and small) subcomponent should have

I think that’s a design flaw and a case where props drilling is problematic. it creates major indirection: difficult to follow where to data comes from and what’s done to it.

This really could be a proper case to use a business hook (as proposed by @jacomyal @sim51)
to be discussed

TimetableV2

useTrainSchedulesDetails is receiving setTrainSchedulesDetails, which comes from TimetableToolbar props, which comes from a state in TimetableV2.

@clarani clarani added kind:enhancement Improvement of existing features area:front Work on Standard OSRD Interface modules labels Jul 2, 2024
@clarani clarani changed the title Technical debt pathfinding component front: technical debt pathfinding component Jul 2, 2024
@anisometropie anisometropie changed the title front: technical debt pathfinding component front: technical debt with data transformation Aug 21, 2024
@anisometropie
Copy link
Contributor Author

anisometropie commented Sep 9, 2024

09/09 Meeting report :
were present: @anisometropie @SarahBellaha @emersion @kmer2016 @Uriel-Sautron

Observation: there is a lot of different state in different places (instead of having one or fewer sourcers or truth like in redux) and each place has ramifications (setters given to children who do transformation on parents state up 3-4 components hierachy,

Todo :
List all the main states used in tsv2. For each main state :

  • where it is used
  • where and how it is transformed.

it concerns main business data such as operationalPoints, pathSteps, currently stored in a useState() ``ManageTrainScheduleV2 pathProperties.

If this is data that was initially in redux store, transformed, and store in a different useState(), This could be a case where the data would be better kept in the store and transformed with a selector.

From these observations, think about possible design solutions

  • using action/event functions. Functions clearly named, called by a react component directly (clicks, events,). These functions are defined in parent component/hooks where the state is defined.

Low level transformation should not be exposed in children components. (details of the operations done on the data should only appear in parents)
for example in stdcmViewV2

const handleStartNewQuery = () => {
    setSimulationsList([]);
    setSelectedSimulationIndex(-1);
    setRetainedSimulationIndex(-1);
    dispatch(resetStdcmConfig());
  };
  • using redux ?

Can ManageTrainScheduleV2 setPathProperties be moved to the existing hook usePathProperties ?

@anisometropie anisometropie self-assigned this Sep 11, 2024
@anisometropie anisometropie added the kind:refacto-task Task related to Refactorization Epic label Sep 11, 2024
@anisometropie
Copy link
Contributor Author

anisometropie commented Sep 23, 2024

example: bug #8935

we have to trace back spaceTimeData up 4 components/hooks to know where it’s created.

SimulationResults => spaceTimeData
=> ScenarioContent => useScenarioData =>projectedTrains => projectedTrainsById
=> useLazyLoadTrains
=> useLazyProjectTrains

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:front Work on Standard OSRD Interface modules kind:refacto-task Task related to Refactorization Epic
Projects
None yet
Development

No branches or pull requests

2 participants