If there is already some business object (Facade) representing some specific task... other business componenets should use it. They should not reimplement it again.
To say it clearly explicitly:
Other layers (presentation, scheduled job) should call only one Business API (service/facade)
This Business Service/Facade should do its job, and if needed it should call other Business Service(s)/Facade(s) and ask them to do their job.
That service should NOT call DAO if this is already implemented elsewhere.
# 1 楼答案
我喜欢这个问题,因为我必须找到答案,然后说服其他人。。。因此,根据一些项目的经验,我的观点是:
业务层应该由负责某些任务的组件(我将它们命名为^{} )构建。例如
Persist(entity)
)CreateNew()
,返回带有一些基本业务设置的新对象(预填充的国家/地区、货币…)李>Find(filter)
加载一些数据我可以继续,但最后,我会看到外墙,它们真的在做他们的任务,并对他们负责。这意味着我们找到了答案
所以,如果有BL人员,准备从DAO获取数据或将其他数据传递(并验证)到DAO中。。。我们应该用它
最后,我们制定了DRY和SOLID原则。。。代码变得易于维护和扩展。例如,如果我们知道只有一个
EmployeeFacade.Find(filter)
,就很容易引入AOP,并确保所有结果都可以被截获