Code Simplicity

Powered By WordPress
Theme Based On A Design By Jared Quinn.

Clues to Complexity

Posted by Max Kanat-Alexander
On November 17th, 2011 at 11:11

Permalink | Trackback | Links In

Category: Uncategorized

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

Comments RSS | Trackback URI

11 Comments »

+/- Comment by Andrew Pennebaker at 2011-11-17 12:14:57

• 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.

+/- Comment by Max Kanat-Alexander at 2011-11-17 21:12:26

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

 
 
+/- Comment by John at 2011-11-17 12:30:46

How about “Management seriously considers hiring more than one manager to manage the developer working on a single class or file” :)

+/- Comment by Max Kanat-Alexander at 2011-11-17 21:12:36
 
 
+/- Comment by Jerome at 2011-11-17 12:56:56

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.

+/- Comment by Max Kanat-Alexander at 2011-11-17 21:13:31

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

 
 
+/- Comment by Simon at 2011-11-17 17:32:50
+/- Comment by Max Kanat-Alexander at 2011-11-17 21:13:45

Hahahaha!! WTF indeed!!

-Max

 
 
+/- Comment by Raghu at 2011-11-17 21:54:52

After reading Simon’s comment above, I went to the site and found this.

http://thedailywtf.com/Articles/Serious-String-Validation.aspx

~raghu

 
+/- Comment by Palo at 2011-11-29 01:02:52

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”)

+/- Comment by Max Kanat-Alexander at 2011-11-29 01:16:53

Hey Palo! Thanks for your kind words! :-)

Yeah, I agree, “it’s too easy to make a mistake” is a very good one. :-)

-Max

 
 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.