下面三个流畅的表达方式中哪一个最符合用户故事?

发布于 2024-10-31 09:54:12 字数 645 浏览 0 评论 0原文

我正在开发一个流畅的框架,我希望从其他工程师那里获得一些反馈,了解哪种流畅的表达方式与我拥有的用户故事最一致。

用户故事:“作为使用 Fluent Framework X 的软件工程师,当框架的事件聚合器发布事件时,我希望将此事件映射/路由到我的控制器上的方法,然后在 UI 容器中显示视图。”

选项 1:

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

选项 2:

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

选项 3:

Map<MyEvent>()
.To<MyController>(controller => controller.HandleMyEvent())
.Show<MyView>()
.InContainer<MainTabContainer>();

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>();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薆情海 2024-11-07 09:54:12

“作为一名使用 Fluent 的软件工程师
框架 X,当框架的
事件聚合器发布一个事件,我
想要将此事件映射/路由到
我的控制器上的方法,然后显示
UI 容器中的视图。”

这听起来像是您希望代码表达的内容:
将事件 X 发送到我的控制器并在 UI 容器中显示结果。
然后你将其输入 google English-to-C# 翻译器,你会得到:

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

在设置事件路由时指定视图和控制器。需要指定视图-控制器映射,但不能与设置事件路由在同一句话中。所以单独做:

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

或者将控制器绑定到视图,然后将事件路由到视图,而不是控制器,但我不会。坚持通过控制器路由事件。

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

榆西 2024-11-07 09:54:12

如果没有系统的整个上下文,就很难说。例如,我不知道 UI 容器的作用,为什么它只在选项 3 中定义,以及它对于前两个选项意味着什么。我假设有一些约定来决定默认使用哪个 UI 容器。

选项 1 看起来不像自然句子,并且连续两个通用参数使其可读性低于选项 2 和 1。 3.

选项3包含两个句子,Show是这里的第二个动词。我喜欢每条链只有一句话的 API,但这可能只是我个人的偏好。

选项2是一个自然的句子,意思明确,单词简短,我最喜欢它。如果有一种方法可以覆盖默认的 UI 容器(使用诸如 To().In() 之类的东西),那绝对是最好的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文