Dealing with spaghetti code

1412035200

If you’ve been working as a programmer for a while, you’ve probably inherited code from past developers. Code that makes no sense, is hard to follow, and when you finally understand it and change something, it breaks.

Why would anyone write code like this? What were the previous developers thinking?

The truth is that it could happen to any of us. Management sets a deadline and we’re in a rush to deliver. Whenever we’re in a rush, we don’t pay attention to the small things or follow our best practices, and if we ignore them long enough we make a mess.

Working with messy code slows us down. We know that. Changes that should take minutes now take hours, or even days. The trade-offs of ignoring our disciplines are just not worth it, and yet we do it all the time.

We need time to write code well, that’s a fact. What we should do is learn how to communicate truthfully with management when we know their deadlines can’t be met. They don’t know about code, they trust us to tell them how things really are. They are counting on it so they can make further commitments with our clients.