Good Things About Hardcoding

Everybody agrees on hating hardcoding. In fact, to many it is probably among the worst of programming sins.
But is hardcoding really all bad? I don’t think so. It has some good properties:

Development Time
It is fast. Just writing code takes less time than thinking out abstractions and then writing the code.

Performance
Hardcoded means fast. At least, it can. Essentially, it’s inlining functionality that would otherwise have to be executed through a number of abstractions. Calling a function takes clock cycles.

Simplicity
Fewer abstractions to understand and memorize can make your system simpler to work with.

Readability
Hardcoding makes your code easy to read. If you’re like most programmers, you will turn away with a snort of disgust when you spot some code that is definitely hardcoded. Nevertheless, chances are that you can easily tell what the code does. This is something that can be much harder with properly refactored code.



Leave a Reply

-->