Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
switchlink.h
toswitchlink_defs.h
.switchlink_types
toswitchlink_defs
.switchlink_types.h
fromswitchlink_defs.h
.switchlink_db_types.h
fromswitchlink_db.h
.switchlink_types
andswitchlink_db_int
bazel targets.The main objective of the refactoring was to separate the data type definitions from the function prototypes. This resulted in cleaner, more precise dependency declarations in the Bazel build system.
It is also a better design, in that it enforces separation of concerns between the data type definitions and the API.
The distinction became apparent when I looked into the possibility of converting switchlink from C to C++. The API is tightly coupled to the class interface, since it defines the methods; the data types are loosely coupled, and could easily go in another header file.
The process separating the definitions was as follows:
switchlink.h
and name itswitchlink_types.h
.switchlink.h
.switchlink_types.h
.switchlink.h
toswitchlink_defs.h
. (This allowed me to create separateswitchlink
andswitchlink_defs
targets in Bazel.)switchlink_db.h
and name itswitchlink_types.h
.switchlink_db.h
.switchlink_types.h
.switchlink.h
toswitchlink_defs.h
.It was verified by:
main
branch.switchlink.h
andswitchlink_db.h
to a temporary directory.header-file-refactoring
branch.temp/switchlink.h
withswitchlink_defs.h
.temp/switchlink.h
withswitchlink_types.h
.temp/switchlink_db.h
withswitchlink_db.h
.temp/switchlink_db.h
withswitchlink_db_types.h
.It was obvious from the side-by-side comparison that a block of definitions had been transferred, intact, from
switchlink.h
toswitchlink_types.h
, and fromswitchlink_db.h
toswitchlink_db_types.h
.