你如何组织你的代码库?
我很想知道人们如何组织他们的代码库,特别是在可重用组件方面。 我在下面用面向对象的术语进行讨论,但我也对您如何组织其他类型语言的库感兴趣。
例如:
- 您是否对所有内容都坚持使用类库项目,还是更喜欢将所有内容保留在一个项目中?
- 您是否重用预构建的 DLL,或者是否在当前工作中包含以前项目中的各个类? 如果是单独的类,您是否在项目之间共享它们以确保所有类都保持最新,或者您是否允许分支?
- 您的可重复使用元素有多大? 他们有多专注? 他们的注意力如何集中?
- 通过您的首选实践,您能达到什么程度的重用?
编辑
我不是在
这里寻找具体的指导,我只是对人们的想法和实践感兴趣。 我对不同项目之间(而不是单个项目内)代码的重用特别感兴趣。 (不幸的是,这里使用“项目”具有误导性 - 我的意思是为客户进行的实际项目之间的重用,而不是 Visual Studio 意义上的项目。)
I am interested to know how people organise their code libraries, particularly with respect to reusable components. I am talking in OO terms below but I am interested in how your organise libraries for other types of language also.
For example:
- Are you a stickler for class library projects for everything or do you prefer to keep everything in a single project?
- Do you reuse your prebuilt DLLs or do you include individual classes from previous projects in your current work? If individual classes, do you share them between the projects to ensure all are kept up to date or do you permit branching?
- How large are your reusable elements? How focussed are they? How are they focussed?
- What level of reuse do you attain through your preferred practices?
etc.
EDIT
I am not looking for specific guidance here, I am just interested in people's thoughts and practices. I am particularly interested in the reuse of code between disparate projects, rather than within a single project. (Unfortunately the use of 'project' here is misleading - I mean reuse between real-world projects undertaken for customers, not projects in a Visual Studio sense.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
通常可以通过部署注意事项来指导:
您将如何部署(即您将在生产计算机上复制什么)?
如果您要部署的是打包组件(即dll、jar、war...),那么明智的做法是将“代码库”组织为打包的集合文件集。
这样,您将直接使用 dll、jar、war 等进行开发,这些将部署在生产平台上。
这个想法是:如果它可以与这些打包文件一起使用,那么它仍然可以在生产中使用。
我认为这种重用在“组件”方法中更容易(就像问题“GIT 中的供应商分支”)
在当前的 40 多个项目中,我们
这些技术组件被重用到所有其他项目中。
摘要:
对于大型功能域,单个项目难以管理,良好的应用架构将导致自然的代码重用。
It generally can be guide by deployment considerations:
How will you deploy (i.e. what will you copy on your production machine) ?
If what you are deploying are packaged components (i.e. dll, jar, war, ...), it is wise to organize the "code library" as a collection of packaged set of files.
That way, you will develop directly with the -- dll, jar, war, ... -- which will be deployed on the production platform.
The idea being: if it works with those packaged files, it may still work in production.
I maintain that kind of reuse is easier in a "component" approach (like the one discussed in the question "Vendor Branches in GIT")
Over more than 40 current projects, we achieved:
Those technical components are reused into every other projects.
Summary:
For large functional domain, a single project being not manageable, a good applicative architecture will lead to natural code reuse.
我们遵循以下原则:
您可以通过此处和此处。
We follow these principles:
You can find out more over here and over here.
这取决于你工作的平台。 我是一名(自豪的)Java 开发人员,我们有很好的工具来组织我们的依赖项,例如 Maven 或 常春藤
It depends on what platform you work. I'm a (proud) Java developer and we have nice tools to organise our dependencies such as Maven or Ivy
无论您决定做什么,良好的源代码控制对此都至关重要,因为它允许您以任何您喜欢的方式实施您的策略,而不会最终产生大量不相关的库副本。良好的分支支持至关重要。
Whatever else you decide good source code control is crucial to this,as it allows you to implement your strategy whatever way you like without ending up with lots of unrelated copies of your libraries.good branching support is essential.