I’m expanding an application I built for a client a couple of years ago. I’m currently a Rails developer with a whole bunch of Best Practices in my toolbox but at the beginning of 2005 I’d never seen the inside of a well-designed large data web app.
Looking at some of this code I cringe and catch myself thinking “I hope nobody else ever sees this crap.” It gets the job done, but it’s just so damn brittle. Here are some things I did very, very wrong:
Posted form variables aren’t enclosed in a parent var. I have things like
Application-layer lists of data. I’ve got stuff that should, by all rights, be in its own db table in some php array.
Everything is overly complex and connected. When I could have just written html files (‘views’ in MVC talk) I opted for functions like tr() and td() and make_table_row() that take wild and varying arguments.
Did I learn anything from looking at this code? Yeah. The only thing that I earn by taking the shortcut while coding is the chance to make a stupid blog post about it. I’d give my left arm to know then what I know now. Well, actually no. I’d give, like, $200. Not an arm - then I couldn’t code.