Here are some clues that tell you that your code may be too complex:
- You have to add “hacks” to make things keep working.
- Other developers keep asking you how some part of the code works.
- Other developers keep mis-using your code, and causing bugs.
- Reading a line of code takes longer than an instant for an experienced developer.
- You feel scared to modify this part of the code.
- Management seriously considers hiring more than one developer to work on a single class or file.
- It’s hard to figure out how to add a feature.
- Developers often argue about how things should be implemented in this part of the code.
- People make utterly nonsensical changes to this part of the code very often, which you catch only during code review, or only after the change has been checked in.
That’s what I can come up with off the top of my head. What are some others?
-Max
Subscribe in your feed reader
• The code doesn’t play well with other code (weak or no API).
• Each function seems to require a custom input type.
• Compilation or interpretation is slow.
• The project requires several programming languages.
• It would be really hard to decouple the project with its dependencies or switch to alternative libraries.
• Developers talk about rewriting the whole thing from scratch.
Yeah, those are good!
Although I wouldn’t say that slow interpretation/compilation or the need for several languages are necessarily indicators of complexity. Some languages just have slow compilers, some projects are just large, and sometimes you have to use multiple tools to get the job done.
-Max
How about “Management seriously considers hiring more than one manager to manage the developer working on a single class or file”
Hahahaha!
A few other ones:
- Your methods parameter lists grows out of control over time.
- You feel the need to comment your control block endings (I call it ‘if’ inflation)
- Writing a good coverage test would require more code than the method you want to test.
Yeah! Those are pretty good!
Although, as far as test-writing goes, I’ve actually found it pretty common that tests can be larger than code. I think that’s probably more an issue of the complexity of the requirements as opposed to the complexity of the code.
-Max
The dependency tree looks like this?
http://thedailywtf.com/Articles/Enterprise-Dependency-The-Next-Generation.aspx
Hahahaha!! WTF indeed!!
-Max
After reading Simon’s comment above, I went to the site and found this.
http://thedailywtf.com/Articles/Serious-String-Validation.aspx
~raghu
Hi Max, I really like your blog posts. Last year I was working on a batch system for computing statistics from large datasets. I order to add a new bussiness rule I had to check and/or modify several non-related places including spring beans, property files and other stuff, all of these were trivial, but it was easy to make a mistake (for example there was a DB2/Oracle decimal/integer issue which no-one got right at the first time). So I think that a system is complex when it’s very easy to make a mistake (the consequence is “You feel scared to modify this part of the code”)
Hey Palo! Thanks for your kind words!
Yeah, I agree, “it’s too easy to make a mistake” is a very good one.
-Max