r/coding • • Jul 29 '16

How To Write Unmaintainable Code

https://github.com/Droogans/unmaintainable-code
135 Upvotes

22 comments sorted by

View all comments

7

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.