The Pragmatic Craftsman :: Simplicity from complexity : by Stanley Kubasek ::

Simple is Beautiful

Programmers love complexity. We love to make things that are complicated.

Why is that? I think it’s because programmers think that it makes them look good. :-) I think they feel they accomplished something big. Or is it that it gives them job security? (probably not) :-)

What’s the root of the problem? I think it’s jumping into code right away. We all love to code, and the first thing we do when we have a problem to solve is try to hash it out in code. Once you start, you try to resolve any issues that arise any way you can. It’s harder to make changes once you start coding, though. Especially when you’re working on something complex and the deadline approaches… So you’re trapped.

The issue here is that programmers forget about a fundamental step in good design: to think about the problem first and design it at high level first. Go through the problem at high level, even if it’s just in your head, or on a piece of paper. Go through the whole scenario. Simple UML here helps as well. By doing so, you might encounter issues that are easy to solve at this high level, but not when you’re coding.

Thinking through the problem usually results in good layers. It usually results in a good domain logic. It usually results in better architecture. It results in higher quality code.

This way of high-level thinking introduces you to thinking abstractly: a required skill in design/architecture.

Not thinking through the problem usually results in spaghetti code. That’s just the way it is, whether you like it or not. And even though you might think it does not happen to you, I think it happens to everyone. You might be an expert in refactoring, and you might be able to get a clean solution, but I say you have a higher chance of just leaving things the way they are.

Here’s what Allen Holub had to say in Holub on Patterns.

“Simple systems are easier to build, easier to maintain, smaller, and faster than complex ones. … Simplicity is often not an easy goal to achieve. Programmers love complexity, so they have a strong tendency to over complicate their work. It’s often easier to quickly build an overly complex system than it is to spend the time required to make the system simple.”

To me, the hardest thing in programming is making things simple. Programming itself, is like managing complexity. In my opinion, that’s the single most important quality of a good programmer: the ability to make complex things look simple. I think the lack of it keeps people programming, instead of moving on to designing and architecting. I think most of us want to eventually be more involved in design and architecture, but until we master the principle of making things simple, we’ll be stuck programming — even though we might have a title of an “architect.”

Look at design patterns. They changed the way we look at design. But fundamentally, behind the scenes, design patterns make complicated problems simple. Patterns are really a facade to complicated problems/issues. And that’s the beauty of patterns.

“Simplicity is prerequisite for reliability,” said Edsger W. Dijkstra.

On a related note, if you’re working on something that’s complex and not very pretty, try not to make it worse. Refactor it to make it easier. We don’t usually have the time to do a “big bang” refactoring, but a little here and there helps. One of the principles that I try to follow is to never make things worse than they are. I always try to look for ways to make things better. To me, simple is beautiful.

Stanley

Favorite Quote

Topics

Tags

Archive

Currently Reading

Info

© 2001-2024 Stanley Kubasek About me :: Contact me

Me on Twitter

»see more

Recent Entries