Closed ChristianTackeGSI closed 2 months ago
Common learnings
``` Learnt from: ChristianTackeGSI PR: FairRootGroup/FairRoot#1585 File: fairroot/base/sim/FairGenericStack.h:51-55 Timestamp: 2024-09-10T19:05:56.200Z Learning: The `SetCurrentTrack` method in `FairGenericStack` centralizes the responsibility of setting the current track, promoting code reuse and reducing duplication in derived classes. ```
How does the move of
fCurrentTrack
fromFairStack
toFairGenericStack
influence downstream projects, which (for exampleclass PndStack : public FairGenericStack
) also declarefCurrentTrack
. Will all the project need to get rid of such variable shadowing?
No, they don't need to change anything.
That's why fCurrentTrack
is private
, so that no deriving classes can see / use it at all. They don't even know it exists. They can only interact with the methods.
And if they don't like any of this, they can override the methods as they already did. No changes should be necessary.
But if they're happy with the "default" implementation, they can strip theirs (like in the templates) and reduce their code sizes.
Instead of letting each derived "Stack" implement everything, provide some basic functionality in FairGenericStack.
Derived classes can just use it, extend it, or completely replace, as they see fit.
Checklist: