3

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>();
CedricB
  • 1,157
  • 9
  • 23

2 Answers2

1

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.

NOtherDev
  • 9,542
  • 2
  • 36
  • 47
  • it would be very hard to give you the entire context of the system. There is no way in the current system to specify a target container (that I am aware of), and the current framework shows the view contitionally, based on what the controller's HandleMyEvent returns. Option 1 & 2 exist, and they hurt my brain. The "user story" is what I have to do, and I was really curious if Option 3 best describes the user story. – CedricB Apr 08 '11 at 21:38
1

"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.

THX-1138
  • 21,316
  • 26
  • 96
  • 160
  • thank you for your suggestion... I like it "Route().To(c=>c.HandleMyEvent()).AndShowResultIn();" – CedricB Apr 11 '11 at 18:22