跨模块通讯 [英] Cross-module Communication

查看:71
本文介绍了跨模块通讯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很简单,将应用程序的各个部分组合到适当的模块中当然是很有意义的.

Quite simply, it of course makes good sense to group parts of an application into appropriate modules.

常见的是,保持这些模块的分离不是问题,但是它常常使其他组件需要来自用户管理模块的数据.

Commonly, keeping these modules decoupled is not an issue, however it often arrises that data from the a user management module is required by other components.

这些正常情况下,这些客户端模块了解用户模块的内部类等知识远非理想,这使我想到了如何最好地构建这种跨模块通信的问题.

It is substantially less than ideal by normal principles that these client modules would have knowledge of the user module's internal classes etc, which brings me to the question of how this cross-module communication is best architected.

到目前为止,我的想法是一个模块可以具有一个常规命名的API类,其他模块可以通过该类来查询"该模块.这种方法仍会导致一定的依赖关系,但至少只能依赖于其他模块/它的API.

My thoughts thus far are that a module could have a conventionally-named API class via which other modules could 'query' the module. This approach will still lead to a certain dependency, but at least only on the other module/its API.

您对此的想法将受到极大欢迎.

Your thoughts on this would be greatly welcomed.

预先感谢, 詹姆斯

推荐答案

您可以将用户模块称为库".此术语更改可以帮助阐明哪些模块应该是顶级模块,哪些模块应该管理打算由多个其他模块使用的较低级别的活动. CodeIgniter PHP框架使用这种方法.

You could call the user module a "library". This terminology change can help clarify which modules are supposed to be top-level, and which ones manage lower-level activities that are intended to be used by multiple other modules. The CodeIgniter PHP framework uses this approach.

这篇关于跨模块通讯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆