程序设计 - 按功能与层或两者打包? [英] Program Design - Package by Feature vs. Layer or Both?

查看:174
本文介绍了程序设计 - 按功能与层或两者打包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正处于Web应用程序的设计阶段,该应用程序允许用户创建工作请求,工作人员可以根据这些请求投入时间。该应用程序还将为主管提供报告功能,以获取每日总计,报告和帐户所花费的时间,成本分配。

I am in the design stage of a web application that allows users to create requests of work and the workers to put time against those requests. The application will also have reporting capabilities for supervisors to get daily totals, reports, and account for time spent, "cost allocation".

我在过去是使用逐层方法设计的。我认为通过功能设计使用包会更有效,我对这个设计有疑问。

Applications I've worked on in the past have been designed using the package by layer approach. I'm thinking it would be more efficient to use a package by feature design and I have a question about this design.

我目前正在考虑的功能包:

What I am currently thinking for the packages by feature:


  1. 请求 - 请求CRUD,然后分配,添加发票号等...

  2. 工作时间 - 用户针对请求,假期,培训或会议的每日CRUD

  3. 成本分配 - 创建报告,会计师想要的会计事项......

前端将是Tomcat服务器和JSP。而且,后端将是一个Oracle数据库,EclipseLink执行持久性。

The front-end will be Tomcat server and JSP. And, the back-end will be an Oracle database with EclipseLink doing the persistence.

我的问题:

在我对功能包的理解中,实体和DAO会进入包与他们相关联。在多个包中展开持久层。将包从其他包中调用实体。所有的重叠是否真的有用?包之间没有隔离。使用打包功能有什么优缺点?使用额外的持久层是否是一个好的设计?或者,我是否完全理解这一点?

In my understanding of package by feature, the entities and DAOs would go into the package associated with them. Spreading out the persistence layer across several packages. Leaving packages to call entities from other packages. With all of the overlap is this really functional? There would be no isolation between the packages. What are the pros and cons to using package by feature? Would it be good design to go with an additional persistence layer? Or, do I have the understanding of this totally wrong?

推荐答案

我建议根据业务实体启动包装。在那里你可以根据图层划分东西。

I would suggest to start package things based on business entities. And in there you can divide things based on layers.


所有的重叠是否真的是
功能?

With all of the overlap is this really functional?

我正在练习它很长时间。我认为这种方法没有任何重大问题。您必须找出要解耦的内容以及应该解耦的内容。例如,使用提供的API从 customer 包中调用 orders 的持久方法订单对我来说非常好。

I am practising it for long. I don't see any major issues with this approach. You must find out what to decouple and how much it should be decoupled. For example, calling a persistent method of orders from a customer package using the API provided by orders is pretty fine for me.


使用
包的优缺点是什么?功能?

What are the pros and cons to using package by feature?

我认为它比简单的面向层包装更简单,直观,易懂,易于使用。当你想要将东西拆分并分配到不同的地方时,它会有所帮助。

I find it more simple, straight, understandable and easy to work with than strict layer oriented packaging. It benefits when you want to split and distribute things to different places.


附加
是否是一个好的设计持久层?

Would it be good design to go with an additional persistence layer?

看看这个SO线程,我发现JPA,或类似的,不鼓励DAO模式

进一步阅读

  • Generic Repository and DDD

这篇关于程序设计 - 按功能与层或两者打包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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