Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

which of the three fluent expressions below best matches the user story?

I am working on a fluent framework, and I was looking to get some feedback from other engineers as to which fluent expression is the most aligned with the user story that I have.

User Story: "as a software engineer using fluent framework X, when the framework's event aggregator publishes an event, I want to map / route this event to a method on my controller and then show a view in a UI container."

Option 1:

Map<MyEvent>()
.To<MyView, MyController>(controller => controller.HandleMyEvent());

Option 2:

Map<MyEvent>()
.To<MyView>()
.Via<MyController>(controller => controller.HandleMyEvent());

Option 3:

Map<MyEvent>()
.To<MyController>(controller => controller.HandleMyEvent())
.Show<MyView>()
.InContainer<MainTabContainer>();
like image 224
CedricB Avatar asked Dec 02 '25 04:12

CedricB


2 Answers

"as a software engineer using fluent framework X, when the framework's event aggregator publishes an event, I want to map / route this event to a method on my controller and then show a view in a UI container."

here is what it sounds like you want your code to say:
send event X to my controller and show result in a UI container.
then you feed that into google English-to-c# translator and you get:

Route<MyEvent>().To<MyController>(c=>c.HandleMyEvent()).AndShowResultIn<MyUIContainer>();

Specifying both view and controller when you setup event routing. View-Controller mapping needs to be specified, but not in the same sentence as setting up event routing. So do it separately:

Bind<MyView>().To<MyController>();

or bind controller to the view, and then route event to the view, instead of controller, I wouldn't though. Stick with routing events through controller.

like image 100
THX-1138 Avatar answered Dec 03 '25 18:12

THX-1138


It is a bit hard to say without the whole context of your system. For example I don't know the role of UI container, why it is defined only in Option 3 and what does it mean for two first options. I'll assume that there is some convention that decides which UI container to use by default.

Option 1 doesn't look like natural sentence and two generic parameters in a row make it less readable than Option 2 & 3.

Option 3 contains two sentences, Show is the second verb here. I like APIs that have one sentence per chain, but that may be only my personal preference.

Option 2 is a natural sentence with clear meaning and short, single words, I like it the most for sure. If only there's a way to override the default UI container (using something like i.e. To<MainTabContainer>().In<MyView>()), it will be definitely the best.

like image 41
NOtherDev Avatar answered Dec 03 '25 18:12

NOtherDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!