Facade 放入每个包中,还是必须有一个仅用于 Facade 的包?
Facade 类必须去哪里?假设我有三个包,Facade A 放入包 A 中,Facade B 放入包 B 中,Facade C 放入包 C 中,或者我只需要一个单独的包用于 Facade?
还有什么比较推荐的呢?
我正在使用第一个解决方案,但我认为这是不对的。某些类使用外观来分配该类未使用的一些对象。
Where the Facade classes must go? Supposing I have three packages, Facade A goes inside Package A, Facade B goes inside Package B and Facade C goes inside Package C or I need a separate package only for Facades?
What is more recommended?
I'm using the first solution, but I think is not right. Some classes are using a facade that allocates some objects that the class not uses.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上取决于您的包的组织方式。
假设您有 payment、hr 和 contacts 包,那么为每个包都有一个外观是有意义的。
如果您以较少域驱动的方式拆分包,例如
services
、dao
和web
,则仅为服务层创建外观会有道理的。It really depends on how your packages are organized.
Suppose you have
payment
,hr
andcontacts
packages, then it would make sense to have a façade for each of them.If you split your package in a less domain driven way, like for example
services
,dao
andweb
then making a facade only for the service layer would make sense.