[英]Why use many sub-projects and dependencies over packages?
I've mostly in my career worked in small or mid-sized java projects. 我的职业生涯主要是在中小型Java项目中工作。 I recently saw a huge project comprising of 30 projects in eclipse.
我最近在eclipse中看到了一个包含30个项目的庞大项目。 I don't really get concept of creating many small projects and then maintain inter-project dependencies.
我真的没有创建许多小项目的概念,然后维护项目间的依赖关系。 When do we prefer this over simply organizing stuff in packages?
我们什么时候更喜欢这个而不是简单地组织包裹?
I guessed it's a maven thing (have mostly been using Ant). 我猜这是一个maven的事情(主要是使用Ant)。 I've been reading up on Maven's concept of modules as well – I saw some links on net recommending creation of different modules for web, dao and service layers under a parent module.
我一直在阅读Maven的模块概念 - 我在网上看到一些链接,建议在父模块下为web,dao和服务层创建不同的模块。 Is it really a common/best practice?
这真的是一种常见/最佳实践吗?
With or without maven – does such division really makes life easier? 有或没有maven - 这种分裂真的让生活更轻松吗? Isn't it more compact to have everything in a single project with well-defined packages structure for different layers?
将所有内容都放在一个具有明确定义的不同层包结构的项目中是不是更紧凑?
It's common to split up projects into API, implementation, web, etc. components–when there's a need to do so. 在需要时,将项目分成API,实现,Web等组件是很常见的。 Large projects are just that: large.
大型项目就是:大型项目。
There are benefits to keeping components separate" 将组件分开是有好处的“
You can do all the same stuff with one giant project, but it's more difficult to determine what goes where, and why. 你可以用一个巨大的项目完成所有相同的工作,但是确定哪些地方以及原因更加困难。 Life is easier when those lines of demarcation are clearly defined.
当明确界定这些划界线时,生活会更容易。
How much easier depends on the project, but when you're dealing with hundreds of thousands of lines of code, occasionally millions, breaking that stuff up saves huge headaches. 更容易取决于项目,但是当你处理数十万行代码时,偶尔会有数百万行代码打破这些代码可以避免巨大的麻烦。
Why choose to create a separate module in maven? 为什么选择在maven中创建一个单独的模块? To help you with your development.
为了帮助您的发展。 There really is no other reason.
真的没有其他原因。
The are a number of different reasons why you may want to create a separate module: 您可能想要创建单独的模块的原因有很多种:
You choose to break up into modules for the same reasons as you would for separating into packages, but at a higher level, at a group of packages. 您选择分解为模块的原因与分离到包中的原因相同,但是在更高级别,在一组包中。
30 does seem excessive. 30看起来似乎过分了。 But there may be good reasons for it.
但可能有充分的理由。 It's up to you and your project to decide what is the right level for the number of modules.
由您和您的项目决定什么是模块数量的正确级别。
Personally, I try not to split excessively, unless there is a very good reason to do so. 就个人而言,我尽量不要过分分裂,除非有充分的理由这样做。
[*] Tangle: mess which describes the links between packages. [*] Tangle:mess描述了包之间的链接。 Package A uses B, which uses C, which uses both A and B. Something which doesn't help understanding.
包A使用B,它使用C,它使用A和B.这些东西无助于理解。
I think excessive modularisation is akin to over engineering. 我认为过度模块化类似于过度工程。 The best route in my opinion is to start with one module/project and keep with that until such point as it becomes obvious to everyone involved that part of this existing module would benefit from being extracted into its own module.
在我看来,最好的路线是从一个模块/项目开始并保持这一点,直到所有参与者都明白这个现有模块的一部分将从提取到自己的模块中受益。 Yes, that means extra work at that point, but for me I'd rather do the work then than endlessly battle with unneeded complexity, in terms of my builds and my development environment, for benefits which are never actually realised.
是的,这意味着在那一点上需要额外的工作,但是对于我来说,我宁愿做完工作,而不是在我的构建和我的开发环境方面与不必要的复杂性无休止地争夺从未实际实现的好处。
Unfortunately there seems to be a tendency at the start of a projects to modularise to the nth degree before even a single line of code is written. 不幸的是,在编写一行代码之前,项目开始时似乎趋向于模块化到n度。
这还有另外一个优点..如果我必须在“选定”组件上部署,我不会浪费时间和资源来部署我不需要的依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.