Factsheet
In BSG when someone is in a military prison they refr to is as being in "hack". Where does the term come from?
What constitutes a hack or hacky code?
Fundamentally, "hacky" code is code that accomplishes some goal by compromising on some principle that people would much rather not compromise on. For example, we might call a program hacky if...
-
It does not follow good style
-
It's grossly inefficient
-
It follows a really awkward design/the flow of logic barely makes sense.
-
The code digs into the internals of some other library/does not respect the contractual interface of the other library
-
The code is brittle and fragile (not robust to external change)
-
etc...
Usually, hacky code arises when people are either rushed for time (and so must compromise on something in order to get the job done), or didn't know what they were doing and either didn't know that they were violating some principle, or weren't experienced enough to care.
Or more generally speaking, the term "hack" will refer to a quick job that does what's needed, but poorly. Consequently, code stops being hacky when it no longer violates these principles of good style and design.
Somewhat confusingly, calling something "hacky" can also be a sort of compliment, based on context. If you're rushing, and barely manage to get something working against all odds, people might call it a "hack" in a sort of admiring/how-the-fuck-did-you-get-that-working tone of voice.
Even more confusingly, the term "hack" can sometimes also mean to either "explore" or "playfully experiment with". The idea is that if you're exploring/experimenting, you're unlikely to write code that follows all the principles of good style because you're liable to throw the code away very soon, and eventually the term "hacking" became in a sense synonymous with the term "exploring".
(And we circle back around -- if people start actually using that exploratory code/nobody bothers to fix it, then you're basically stuck with a hacky codebase and now everybody's miserable).
However, while I can spout definitions, I think the best way to get an intuitive feel for what counts as a hack is to actually instead learn what counts as good code (if you're interested, there are many books that teach the principles of good style -- for example, see Code Complete).
Once you understand what good code should look like, it'll be much easier to spot hacky code -- you feel a sort of instinctual revulsion towards it (or sometimes a fascinated revulsion).
More on reddit.comVideos
This has been bugging me for a while. Is "hack" an acronym or maybe a military term that I haven't heard before?
I've seen the term used, and have had co-workers use it from time to time when talking about older parts of a system. My question is, what do you consider to be a hack or hacky code? When does it stop being a hack, and start being good code?
Fundamentally, "hacky" code is code that accomplishes some goal by compromising on some principle that people would much rather not compromise on. For example, we might call a program hacky if...
-
It does not follow good style
-
It's grossly inefficient
-
It follows a really awkward design/the flow of logic barely makes sense.
-
The code digs into the internals of some other library/does not respect the contractual interface of the other library
-
The code is brittle and fragile (not robust to external change)
-
etc...
Usually, hacky code arises when people are either rushed for time (and so must compromise on something in order to get the job done), or didn't know what they were doing and either didn't know that they were violating some principle, or weren't experienced enough to care.
Or more generally speaking, the term "hack" will refer to a quick job that does what's needed, but poorly. Consequently, code stops being hacky when it no longer violates these principles of good style and design.
Somewhat confusingly, calling something "hacky" can also be a sort of compliment, based on context. If you're rushing, and barely manage to get something working against all odds, people might call it a "hack" in a sort of admiring/how-the-fuck-did-you-get-that-working tone of voice.
Even more confusingly, the term "hack" can sometimes also mean to either "explore" or "playfully experiment with". The idea is that if you're exploring/experimenting, you're unlikely to write code that follows all the principles of good style because you're liable to throw the code away very soon, and eventually the term "hacking" became in a sense synonymous with the term "exploring".
(And we circle back around -- if people start actually using that exploratory code/nobody bothers to fix it, then you're basically stuck with a hacky codebase and now everybody's miserable).
However, while I can spout definitions, I think the best way to get an intuitive feel for what counts as a hack is to actually instead learn what counts as good code (if you're interested, there are many books that teach the principles of good style -- for example, see Code Complete).
Once you understand what good code should look like, it'll be much easier to spot hacky code -- you feel a sort of instinctual revulsion towards it (or sometimes a fascinated revulsion).
I'd consider hacky code to be difficult to read and understand, or code that works but isn't a viable solution long-term (performs badly, doesn't provide full functionality).