# Linux Kernel Module Cheat

##### 38.15.1.1. Userland objects vs header-only

When factoring out functionality across userland examples, there are two main options:

- use header-only implementations

- use separate C files and link to separate objects.

The downsides of the header-only implementation are:

- slower compilation time, especially for C++

- cannot call C implementations from assembly files

The advantages of header-only implementations are:

- easier to use, just `#include` and you are done, no need to modify build metadata.

As a result, we are currently using the following rule:

- if something is only going to be used from C and not assembly, define it in a header which is easier to use

  The slower compilation should be OK as long as split functionality amongst different headers and only include the required ones.

  Also we don’t have a choice in the case of C++ template, which must stay in headers.

- if the functionality will be called from assembly, then we don’t have a choice, and must add it to a separate source file and link against it.