简体   繁体   English

Linux C ++项目源文件目录结构

[英]Linux C++ Project Source File Directory Structure

I'm working on a fairly large C++ project on Linux. 我正在Linux上进行相当大的C ++项目。 We are trying to come up with criteria for organizing our source file directory structure. 我们正在尝试提出组织源文件目录结构的标准。

One thought we have is to have the directory structure reflect our architecture choices. 我们必须想到的是让目录结构反映我们的体系结构选择。 For instance, we would have one root level for our domain classes and another for our boundary classes, and one for our domain-agnostic infrastructure classes. 例如,对于域类,我们将有一个根级别,对于边界类,我们将有一个根级别,而对于与领域无关的基础架构类,我们将有一个根级别。

So in a banking application, we might have a directory called src/domain/accounts, src/domain/customerTransactions, src/boundary/customerInputViews, etc. We might then have another directory called src/infra/collections, src/infra/threading, etc. 因此,在银行应用程序中,我们可能有一个名为src / domain / accounts,src / domain / customerTransactions,src / boundary / customerInputViews等的目录。然后,我们可能会有另一个名为src / infra / collections,src / infra / threading的目录。等

Also, within that structure, we'd isolate interface classes from implementation classes. 同样,在该结构中,我们将接口类与实现类隔离。 We'd do that so clients of interfaces would not be dependent on the directory structure of the implementation classes. 我们这样做是为了使接口的客户端不会依赖于实现类的目录结构。

Any thoughts? 有什么想法吗?

Breaking code into independent parts sounds like a good idea. 将代码分为独立的部分听起来是个好主意。 That would allow you to potentially break stuff into separate units (for autotools: you could have convenience libs for organization, and later even separate them complete into shared libs). 这样一来,您就可以将资料分解为不同的单元(对于自动工具:您可以为组织提供方便的库,以后甚至可以将它们完整地分成共享的库)。

Of course the submodules should contain everything needed to build: headers, sources and build infrastructure (maybe only missing a top-level build definition file which gets included). 当然,子模块应该包含构建所需的所有内容:标头,源和构建基础结构(可能只是缺少包含其中的顶级构建定义文件)。 This will make sure that work can be done on small units (but test the whole thing). 这将确保可以在较小的单元上完成工作(但要对整个过程进行测试)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM