Try Looking at Your Own Legacy Code

  • strict warning: Non-static method view::load() should not be called statically in /hermes/walnaweb12a/b57/moo.greydragoncom/nodsw/sites/all/modules/views/views.module on line 906.
  • strict warning: Declaration of views_handler_argument::init() should be compatible with views_handler::init(&$view, $options) in /hermes/walnaweb12a/b57/moo.greydragoncom/nodsw/sites/all/modules/views/handlers/views_handler_argument.inc on line 744.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /hermes/walnaweb12a/b57/moo.greydragoncom/nodsw/sites/all/modules/views/handlers/views_handler_filter.inc on line 607.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /hermes/walnaweb12a/b57/moo.greydragoncom/nodsw/sites/all/modules/views/handlers/views_handler_filter.inc on line 607.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /hermes/walnaweb12a/b57/moo.greydragoncom/nodsw/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 159.
Leeland's picture

Just had a reason to open up my code archives. Not a big deal, just checkout the older stuff from the Subversion archives and add some new Eclipse projects.

Lions, tigers and bears oh my. What the heck are all those warnings!?

LOL one of the things I started doing a few years back was to start worrying about TDD and code complexity. Somewhere in the last couple of years I added the metrics plugin for Eclipse (http://eclipse-metrics.sourceforge.net/). Which is very nice since it supports complexity checking using a number of different metrics:

  • McCabe's Cyclomatic Complexity
  • Efferent Couplings
  • Lack of Cohesion in Methods
  • Lines Of Code in Method
  • Number Of Fields
  • Number Of Levels
  • Number Of Locals In Scope
  • Number Of Parameters
  • Number Of Statements
  • Weighted Methods Per Class

Sometimes you really should let the past remain the past. I had such fond memories of all these cool and wonderful applications and utilities I wrote years ago at the beginnings of Java. Yet here I was looking at them using the latest Eclipse with all the TDD and metrics warning thumbscrews in place (to keep me honestly doing what I preach) having to view my own legacy code.

This will make far me less critical of other legacy code I have to clean up from now on. Yes, my legacy applications still compiled, they still worked. But code coverage is zero, cyclomatic complexity is up in the 50s for most of my methods (in the hundreds for the control points) and oh my do I really have methods over 200 lines long! This is a very humbling experience.

If you'll excuse me I need to sweep the dirt off the floor, dust the corners and polish the brass in my own legacy code.

Thread Slivers eBook at Amazon