Conversation
louisgreiner
left a comment
There was a problem hiding this comment.
After a very very short review, I think replacing the true/false values by an actual Type increases the readability, however the main issue remains. I'm not sure this is how we should treat that. Also, I don't really know what would be better 😄
@emersion @SharglutDev might have better insights, even tho the issue is more at a conceptual level
|
I'm not familiar enough with the common guidelines in Angular or in the NGE repo. If using Another way we do in OSRD is using objects in function parameters: This way when calling the function, we know to what the |
|
I dont get the OSRD concept, how it fixes our issue. We might can dicuss this once we have more time, but i agree we need an improvment in readability. |
For example, some functions in NGE are like : With the object syntax, this would look like : The initial "trigger" for me was the "double boolean", using the method |
|
The introduction of an explicit AnchorType enum for source/target anchor nodes fits better than a { ... : boolean } argument approach from my point of view. Since the anchor node type is a core semantic element of the graph model, using an enum provides several advantages:
For other method calls where the parameters are not tied to such fundamental domain concepts (e.g., not involving core identifiers like source/target), the lightweight { ... } object approach remains a good and pragmatic choice. However, in this specific case, the enum makes the intended anchor node explicit and unambiguous, improving both clarity and maintainability. Therefore, I vote for using this enum‑based approach, as it aligns the API with the semantic weight of the concept and supports long‑term robustness. (My personal opinion) |
|
Totally fine by me :) |
louisgreiner
left a comment
There was a problem hiding this comment.
(I don't have to time to fully review)
The test files don't build and some typing issue lies in this PR (which are not detected since we do not have enough type checking in the CI).
I'm a bit worried about making these changes that affect so many things so quickly, I would recommend establish a clear strategy, and maybe split in smaller commit and make sure all the commits compile. This would ensure that we don't break too many things
| .classed( | ||
| StaticDomTags.EDGE_IS_TARGET, | ||
| anchorNode === TrainrunSectionNodeAnchor.Source | ||
| ? TrainrunSectionNodeAnchor.Target |
There was a problem hiding this comment.
This does not return a boolean value, which is expected for setting the value of StaticDomTags.EDGE_IS_TARGET
|
I fully agree that we shouldn’t merge this in a hurry — certainly not before we are ready for an internal release. |
louisgreiner
left a comment
There was a problem hiding this comment.
Except these two nits, this looks good to me. Maybe we can point all the places where we should use this, and list them in an refactor issue
| /** | ||
| * Classifies which anchor (node) of a TrainrunSection is being evaluated. | ||
| */ | ||
| export enum TrainrunSectionNodeAnchor { |
There was a problem hiding this comment.
Nit: the name of this enum is a bit long. I also think "node" and "anchor" could refer to the same concept, we could choose only one. Maybe we could do something like:
| export enum TrainrunSectionNodeAnchor { | |
| export enum TrainrunSectionAnchor { |
This is just a proposition, maybe we can find something better
| private filterTrainrunsectionAtNode( | ||
| trainrunSection: TrainrunSection, | ||
| atSource: boolean, | ||
| anchorNode: TrainrunSectionNodeAnchor, |
There was a problem hiding this comment.
Nit: anchorNode is inconsistent regarding the name of the enum TrainrunSectionNodeAnchor
I would use either nodeAnchor (or anchor, if you accept my previous suggestion of enum renaming)
This refactoring replaces the ambiguous
atSource: booleanparameter with the explicitTrainrunSectionNodeAnchorenum. This improves readability, reduces boolean ambiguity,and makes the intent of each method call clearer. Several methods in
TrainrunSectionsView,PerlenketteSectionComponent, and related view logic were updatedaccordingly to use the new enum-based API.