Writing maintainable code requires considerable effort and there are numerous resources available in the form of books and websites to teach this creative art. One can also glean wisdom from learning from mistakes, and with this mind, I found it instructive to read a tongue-in-cheek article by Roedy Green about how to write unmaintainable code. The article has been around since 1997, but I think it wears well.
Don't misunderstand me, by recommending this article I'm not advocating writing unmaintainable code at all. I just think it can be very useful to see some ingenious ways to make code totally confusing and bamboozling so that one can avoid these at all cost.