From f3edf738f78957ca9fd912764bddab04dbb02e6b Mon Sep 17 00:00:00 2001 From: Martin Davis Date: Wed, 6 Nov 2024 11:35:49 -0800 Subject: [PATCH] Update Dev Notes --- DEVELOPER-NOTES.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/DEVELOPER-NOTES.md b/DEVELOPER-NOTES.md index fd0ea8b96a..b81594b608 100644 --- a/DEVELOPER-NOTES.md +++ b/DEVELOPER-NOTES.md @@ -87,4 +87,25 @@ public: * It lowers the number of heap allocations, because it allocates larger blocks of space to store multiple `HalfEdge` objects. * It handles the lifecycle of the `HalfEdge` objects that make up the `EdgeGraph`, because when the `EdgeGraph` is deallocated, the `std::deque<>` and all its contents are also automatically deallocated. +### Use forward declarations in header files +Where possible, in header files use **forward declarations** rather than header includes. +This cuts the include dependency chain, which reduces the recompilation required when a low-level class header changes. +Includes are only needed where the class contents are referred to, not just the class name. + +E.g. use this +``` +namespace geos { +namespace geom { +class Geometry; +} +} +``` +rather than: +``` +#include +``` + +### Use `pragma once` to limit header inclusion + +Use `#pragma once` to limit header inclusion. It is simpler and faster.