DEV Community


Discussion on: Explain "Code Smells" like I'm five

warrenburton profile image
Warren Burton

When you’ve spent a lot of time making things, for example, Lego constructions you’ll begin to see things that while they work, they aren’t very stable or safe over the long term. It’s a form of instinct that you learn when you develop your skills with a system.

You wouldn’t put a laser tower on top of a tall stack of 2-stud bricks if you wanted the tower to withstand an alien attack. If you saw that you’d probably want to put the towers on several stacks of 8-stud bricks. Take that aliens!

Code smells are like that. When you look at code and can see things you know don’t work when the system gets larger or things that will lead to tight binding between separate systems. Those are code smells.

Just because you think a piece of code is smelly doesn’t mean that the code is bad. It does mean you should talk about the code nicely with someone else and find out it’s story if you can. Your code might be the work of many people over a long time and there’s probably a reason that it looks like that.