Java EE最佳设计方法。业务逻辑层? [英] Java EE best design approach. business logic layer?

查看:178
本文介绍了Java EE最佳设计方法。业务逻辑层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的项目使用JSF + Spring + Hibernate。

这是一个我经常被困惑的设计问题。

我目前继承了一个包含dao - > service - > view - > controllerlayered方法的项目。

控制器层/层?目前有所有与前端交互的逻辑对象。我被告知,将 分隔成两个图层/图层是很好的做法,其中控制器图层/图层只包含与前端交互的方法/对象和第二图层?),其中包含 由控制器使用的所有业务逻辑。

1st。)以这种方式划分控制者的目的是什么?

第二。 )是否有任何问题,使它保持当前状态? 目的是以这种方式划分控制器?



您必须在 Service Layer中处理业务逻辑。将业务实体与控制器/ UI层分开的好处:


  1. 您可以重复使用商业实体与另一个客户部分。示例:如果您正在开发基于Web的应用程序作为用户界面,那么以后您还开发了桌面用户界面。在这种情况下,您可以在多个UI中重复使用业务层操作。您还可以使用业务层作为Web服务工作。

  2. 解耦的业务操作更易于管理。如果开发团队的某个人不知道UI代码是如何工作的并且只想纠正某些业务逻辑,他可以做到。
  3. c $ c $> b)如果你是分层体系结构的新手,那么它有什么问题吗?

    将需要一些时间来理解和实现所需的图层。这取决于时间框架和应用要求。如果您打算在您的应用程序中使用以上几点,请使用分层架构,否则请使用当前实现。


    The project I am working with uses JSF + Spring + Hibernate.

    This is a design question that I have often been confused about.

    I currently inherited a project that contains a dao -> service -> view -> controller "layered" approach.

    The "Controller" layer / tier? currently has all logic and objects that interact with the front end. I have been told that it is good practice to separate this into two layers/tiers, where the "Controller" layer/tier only contains methods/objects that interact with the front end and a second layer (bm?) that contains all business logic used by the controller.

    1st.) What would the purpose be of dividing up the controller in such a way?

    2nd.) Is there anything wrong with leaving it the way it currently is?

    解决方案

    1st.) What would the purpose be of dividing up the controller in such a way?

    You must handle the business logic in Service Layer. Benefits of separating the business entities from Controller/UI Layer :

    1. You can reuse the business entities with another client sections. Example : if you are developing a web based application as UI, later you also developed a Desktop UI. In this case you can reuse your Business Layer operations with multiple UIs. You can also use business layer to work as a web service.
    2. Decoupled business operations are easier to manage. If someone from development team has no idea how UI code works and only wants to correct some business logic, he can does.

    2nd.) Is there anything wrong with leaving it the way it currently is?

    If you are new to Layered Architecture it will take some time to understand and implement the desired layers. It depends on time frame and application requirements. If you are planning to use the above points in your application go with layered architecture otherwise go with current implementation.

    这篇关于Java EE最佳设计方法。业务逻辑层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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