如何勾勒出事件驱动的系统?
我正在尝试在 Node.js 中设计一个系统(尝试解决 我之前的问题,使用 Node 的并发性),但我在弄清楚如何制定事物应该如何运行的计划时遇到了麻烦。
我对回调而不是返回值的思考感到非常困惑。流程不是线性的,这真的让我难以起草它。如何绘制事件驱动系统的操作流程?
我需要一些我可以看到的东西,然后说“好吧,是的,这就是它的工作原理。我会在这里重新开始,它会在这里给我返回这些结果。”
图片对此非常有帮助。谢谢。
编辑:我正在寻找比UML更精细的东西,具体来说,它将帮助我从我习惯的阻塞和面向对象的编程结构过渡到我不熟悉的非阻塞和事件驱动的结构。
I'm trying to design a system in Node.js (an attempt at solving one of my earlier problems, using Node's concurrency) but I'm running into trouble figuring out how to draw a plan of how the thing should operate.
I'm getting very tripped up thinking in terms of callbacks instead of returned values. The flow isn't linear, and it's really boggling my ability to draft it. How does one draw out an operational flow for an event-driven system?
I need something I can look at and say "Ok, yes, that's how it will work. I'll start it over here, and it will give me back these results over here."
Pictures would be very helpful for this one. Thanks.
Edit: I'm looking for something more granular than UML, specifically, something that will help me transition from a blocking and object-oriented programming structure, where I'm comfortable, to a non-blocking and event driven structure, where I'm unfamiliar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基于 https://i.sstatic.net/9DDQP.png 你需要的是一个很好的流库,允许您在节点中管道同步和异步调用。
其中一个库是 https://github.com/isaacs/slide-flow-control (查看幻灯片预览也),您需要执行的操作的代码大纲如下。
它是自我文档化的,正如你所看到的,它非常简洁,不需要纯 Nodejs、uml、img 等。
Based on https://i.sstatic.net/9DDQP.png what you need is a good flow library that allows you to pipeline sync and async calls in node.
One such library is https://github.com/isaacs/slide-flow-control (look at the slide preso there too) and the code outline for what you need to do is below.
It is self documenting and as you see it is quite concise, pure nodejs, uml, img's etc. not required.
UML 可能比较合适。我会查看行为图。
UML might be appropriate. I'd look at the behavior diagrams.