Your original question was answered, but just as some unsolicited advice
, speaking from experience (we’ve had projects like this in the past), whoever will be maintaining that 3/6/12+ months later (which could be the future you) will grow to hate this design with a passion.
Decoupling in traditional software is usually a good thing. Decoupling in UiPath xaml’s (or most visual scripting, really) is a royal pain. It doesn’t remove the dependency, it just hides it with an abstraction layer.
I’d highly recommend marrying the two concepts together:
Your classification to a dictionary is a good step (I’d personally go with an enum, but that’s just me). Now instead of the original if/else, do a switch and drag in those workflows and set the arguments, especially if they can vary.
It may seem like more work, but you gain static checks on mismatched arguments, and most importantly also it will automatically update on rename and path changes (which is very easy to miss in dynamic dispatch scenarios, and since you’re keen on refactoring it seems, that will be a thing sooner or later).
(I was going to say here that it also gives a compile time error on missing workflow invoke, but apparently that’s not a thing, which seems like an obvious oversight in the workflow analyzer - it should at least be a warning for any invoke with a relative path…).
Remember that code is read multiple times more than written, therefore the focus when writing code should be way more skewed to make it readable and easy to follow. You never know what will be the skill level of the next person working on the project, and while some base level has to be assumed, you don’t want to make it harder to understand what’s going on than it needs to be.
TL;DR: the original if/else design could be better, but it definitely has pro’s that the dynamic invoke does not have. Before doing any refactorings, always ask yourself “why would someone write something this way?”. The answer might surprise you.