-
Notifications
You must be signed in to change notification settings - Fork 164
Code style guide
Since Kod is limited to the Xcode platform and the two compilers GCC and Clang, we prefer the use of #import
rather than #include
. If you do use #include
, make sure to add a header guard in the style described below.
Don't use an #import or #include when a forward declaration would suffice.
When you include a header file you introduce a dependency that will cause your code to be recompiled whenever the header file changes. If your header file includes other header files, any change to those files will cause any code that includes your header to be recompiled. Therefore, we prefer to minimize includes, particularly includes of header files in other header files.
You can significantly minimize the number of header files you need to include in your own header files by using forward declarations. For example, if your header file uses the File
class in ways that do not require access to the declaration of the File
class, your header file can just forward declare class File
; instead of having to #import "foo/file.h"
.