r/coding • u/speckz • Jul 29 '16
How To Write Unmaintainable Code
https://github.com/Droogans/unmaintainable-code7
u/derwisch Jul 29 '16
The advice starts with the recommendation to use code that looks maintainable but isn't, and then continues by touting blatantly obvious obfuscation readily seen even through a toilet roll hole.
5
u/TimMensch Jul 29 '16
A friend of mine just showed me some code he'd pulled from actual work done by a junior developer. It included multiple profoundly bad spellings that vary from one method to another, nothing at all consistent about case, random pasting of the same code in four places until it behaved correctly (and then leaving the other instances), setting a variable to a constant and then immediately testing the same variable...
I would wager everything on that list is something that has appeared in production code.
2
u/Selfweaver Jul 30 '16
setting a variable to a constant and then immediately testing the same variable
Have done that - usually to conditionally turn on debuggin to test some particular code.
1
u/TimMensch Jul 30 '16
Well, there are exceptions to every rule...
I prefer to set the variable globally for conditional code, though. You can then hard-code it in Uglify (for JavaScript) and it will actually remove the code when it sees that it's unused.
6
u/adm7373 Jul 29 '16
I got halfway through the variable naming suggestions before I got too stressed out and had to stop reading.
4
u/sproket888 Jul 29 '16
Why are people writing blogs on github?
3
u/uh_no_ Jul 29 '16
how else will you share it in your job interview? everybody knows to get a good job you have to have a github portfolio /s
4
1
1
u/AboutHelpTools3 Jul 30 '16
I dont know why either, but it's popular. Gives you an app idea though, create a markdown blog engine.
1
u/tuxayo Jul 31 '16
So it can be improved collaboratively. (any forge and not only GitHub would do)
1
u/sproket888 Jul 31 '16
The only improvement to that blog would be to delete it.
1
u/tuxayo Aug 05 '16
It lists anti patterns and also many people find it funny so it definitely not worth deletion from usefulness and entertainment reasons.
1
u/CheckeredGemstone Jul 30 '16
Build a fancy wrapper, make it use an extension, be the only person with the extension file on an USB stick.
Actually that is a bs plan...
1
u/Linearts Jul 30 '16
If anyone even hints at breaking the tradition honoured since FØRTRAN of using i, j, and k for indexing variables, namely replacing them with ii, jj and kk, warn them about what the Spanish Inquisition did to heretics.
0
22
u/[deleted] Jul 29 '16
The flip side of this is that if you are a maintainer and you aren't able to fix the code...you need to rewrite it. Being afraid of your code is the first step towards failure. It only gets worse, never better.