This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 504
Coding Guideline
Tianyu Li edited this page Jul 25, 2018
·
29 revisions
In the project root directory, there are three major places where you will put code:
-
src
-- This is where the bulk of the code for lives. Anything you expect to be compiled into the release should be here. -
test
-- This is where unit tests, benchmarks, and utility code for them lives.src
should not have dependency going intotest
. -
script
-- Where scripts that support development and testing lives. (e.g. python formatting script, dependency installation).
Almost never will you need to create new directories outside of these.
There can be at most 2-levels of directories under src
, the first level will be general system components (e.g. storage, execution, network, sql, common), and the second level will be either for a class of similar files, or for a self-contained sub-component.
Translated into coding guidelines, you should rarely need to create a new first-level subdirectory, and should probably consult Andy if you believe you do. To create a new secondary directory, make sure you meet the following criteria:
- There are more than 2 (exclusive) files you need to put into this folder
- Each file is stand-alone, i.e. either the contents don't make sense living in a single file, or that putting them in a single file makes the file large and difficult to navigate. (This is open to interpretation, but if, for example, you have 3 files containing 10-line class definitions, maybe they should not be spread out that much).
And one of the two:
- The subdirectory is a self-contained sub-component. This probably means that the folder only has one outward facing API. A good rule of thumb is when outside code files only need to include one header from this folder, where said API is defined.
- The subdirectory contains a logical grouping of files, and there are enough of them that leaving them ungrouped makes the upper level hard to navigate. (e.g. all the plans, all the common data structures, etc.)
A good rule of thumb is if you have subdirectory
As
, you should be able to say with a straight face that everything underAs
is an A. (e.g. Everything undercontainers
is a container)
TBD
TBD
Carnegie Mellon Database Group Website