You could scatter the prototypes across dozens of files buried behind hundreds of preprocessor conditionals. You could scatter the function definitions around and hide them behind preprocessor conditionals in the same way. You could even include a lot of fake prototypes and function definitions just to throw people off. Just to keep yourself organized, you could create a map file that lays out where everything is - BUT DON'T CHECK THE MAP FILE INTO THE CODE REPOSITORY!
Not convention but generally good design. Not using headers means your other files are blind to the interface and can lead to some weird bugs when types don't match up. It also makes maintenance a nightmare because if a change is made it has to be made in lot's of places.
Using this technique, you can include the source file directly and it will function as a header file as long as you define HEADER before doing the include.
For anyone that's interested in emacs but finds the vanilla configuration daunting, there's stuff like spacemacs and doom emacs that tries to provide a better default for newbies to start from.
I went with vanilla emacs and just built up what I wanted from it, but that's not going to be for everyone. Hell, it didn't work out for me either for a long time; the only reason emacs finally clicked for me is it added a package manager, so I set it up, added melpa, and any time something about emacs annoyed me I jumped to the package manager and looked for alternatives. That got me just comfortable enough that I wanted to continue using it, so after that I started aggressively gutting some of the default keybindings, like moving alt+x to ctrl+space (and rearranging a bunch of other things in the process) and it went from the editor I'd try out for a week every couple years and abandon, to becoming my primary editor for most things.
152
u/Bo_Jim Nov 07 '21
Taken to an extreme, this technique could be used to produce 100% functional code that virtually nobody other than the original author could maintain.
I give this 8 out of 10 job security points!
83
u/[deleted] Nov 07 '21
Technically, headers are convention and not necessary. They can be used for function prototypes, but don't have to be.
24
u/SanianCreations Nov 07 '21
Using this technique, you can include the source file directly and it will function as a header file as long as you define HEADER before doing the include.
ngl, I actually kinda like it......
17
u/[deleted] Nov 07 '21
thats illegal im calling the police
12
u/[deleted] Nov 07 '21
What editor/IDE is that?
3
u/Isvara Nov 08 '21
I may have been guilty of something similar 30 years ago. All I'll say is...
#define extern.4
u/YoavArvivvv Nov 07 '21
May I please get the color scheme? It looks great.
2
u/wwelna Nov 07 '21
This is really brilliant. I need to apply this method sometimes awe and confuse others sometimes.
1
u/sohang-3112 Nov 08 '21
Side Note: are you using tmux?