Archive for 2006

DevX review of Structure101


"Getting your arms (and eyes) around large, complex code bases has never been easy, but Structure101 from Headway Software may just be the elegant solution to this age-old problem. Find out how this visual design tool analyzes your enterprise projects and lets you zone in on issues quickly and gracefully."  Full Story by Derek Lane.

 

Complexity Debt – don’t “fix it”, “keep a lid on it”


So you just discovered that your code-base has racked up a whole load of complexity debt. This  maybe explains why progress seems so painfully slow lately. You briefly think of suggesting a major complexity-reducing refactoring effort. This will delay the next release significantly, but foreshorten the time to the following releases. Plus a cleaner, simpler code-base will make the world a nicer happier place, right?

But you don’t suggest this. You’re human and self-preservation is an instict. Precisely because of the recent slow progress, there is a lot of disapointment on the whole product delivery front at the minute. Suggesting another big delay doesn’t feel like the best career move just now.

Luckily there is another, more subtle way to get to that happier place without climbing out on long limbs over thin ice.

Don’t repay the debt in one big painful bang – just keep a lid on it. And watch it begin to disipate as though by magic.

You use personality, charisma, leadership and/or donuts to convince your team that henceforth, they will not add any more complexity debt to the code base. Now watch what happens…

If I need to add to a method with a CC of 20 (where the threshold is say 15) and I add a couple of new paths, then I temporarily increase the complexity from 20 to 22. Uh oh, I said I wouldn’t do that. No problem – I’m working on the method already, so I have a good handle on what it does. I just extract a suitable lump into a new method with a nice helpful name and bingo, I have 2 methods each within tolerance instead of 1 over. The 2 methods are simpler and easier to understand and maintain than the 1 before, and the overall code-base debt just went down a bit. Well, I feel good about this.

But wait. That one new method pushes the containing class over the class-level complexity threshold. Again, I refactor the class while its workings are in my head already (perhaps I use move field or extract class). Again, if the class was previously over-threshold, then I probably just reduced the overall debt a bit more.

The same will happen when anyone trys to add to any overly-complex package. And as the xs framework sets thresholds at every level of design breakout, the developers are relieved of the temptation to “hide” complexity by pushing it up or down the hierarchy. The code-base becomes truly less complex, without anyone really trying.

This is cool enough to be named – how about “KALOI” for “keep a lid on it”.

KALOI is supported by Structure101 and there is more explicit support in the pipeline. More on this later.

 

Structure101 v2 goes GA today


Additions let you see complete slices of a code-base at any level, home in on structural complexity, view dependency graphs in matrix form, and map code items and groups (like tangles) through different hierarchies, slices and perspectives (more download).

 

Structure101 v2 beta 2 released


Structure101 is for contolling architecture and structural complexity. Version 2 introduced slicing and tagging. Beta 2 adds dependency hiding and cross-perspective navigation.

New in v2 beta 2:

  • Context menus (right mouse click) have been added. This introduces the new capability to navigate easily between views (perspectives).
  • It is now possible to tag dependencies as well as items.
  • It is also possible to hide tagged dependencies – I.e. remove them from the model. This is useful for simulating structural changes.
  • Performance problems on Linux and Mac have been fixed.
  • Look and feel on Linux and Mac have been improved
 

Spring 2’s architecture – A single dependency cycle slipped in


The Spring guys have let a single dependency cycle into their architecture. A very small flaw, but it’s a perfect example of why you need to check your code-base at different levels to keep it truly tangle-free.

I did a quick analysis of the Spring Framework some time back and sure enough found their claims of a cycle-free architecture to be correct – a pleasure to behold!

The recent announcement of Spring 2.0 rc4 prompted me to point Structure101 version 2 at same and check they were keeping up the high standard they had set themselves. The Structure101 “notables” quickly took me to the org.springframework.aop package which contains the following tangle:

Springtangle_1

Ok, this is not exactly a fatal flaw, far from it, but it surprised me because I know that Juergen keeps an eye on this stuff. Then I took a look at the leaf package slice (leaf packages being packages that contain classes), and guess what? Not a single tangle.  It is only when you look at the slice one level up that the tangle is apparent:

Springtangle2

Taking a look at the leaf packages contained by these 2 packages:

Springtangle3

(The package names are relative to org.springframework.aop). The dependency between the tagged packages (blue dots) is the one causing the problem. Overlaying the parent package boundaries on this graph, you can see why it is that, although the package diagram is acyclic, dependencies between the parent packages go in both directions, making them cyclically dependent.

Springtangle4

I presume they check only at the flat-package level, which is why this one slipped through the net.

 

Tracking complexity debt


Un-monitored, the complexity of a code-base increases with its size. Jboss and Struts are perfect examples. However monitoring complexity helps you keep complexity debt under control, or even down to zero.

If you publish the last couple of years worth of releases of your project to a Structure101 repository, you’ll probably see something like this in the Structure101 Tracker web application:

Jbossxschart

jboss over time

Structure101 matches the amount of XS to the lines of code that cause it. Unless someone pays attention to it, the same team will tend to code-in a consistent degree of complexity debt as they go – in this case they’re running at a not-unusual but alarming 80%.

Struts shows a similar chart running at about 57% XS:

Strutsxschart

struts over time

I was in with the Prime Carrier guys yesterday. They’ve been tracking their excess complexity for several months now and it really shows.  Here’s the chart for one of their projects:

Pc1

Prime Carrier project 1 over time

As you can see, XS is hugging the zero line even as the size of the code-base grows. This is why we call it “excess” (XS) – it really is excessive and totally avoidable. Occasionally a cyclic dependency (tangle) or fat class may get into the build, but it’s flagged and usually fixed during the next iteration.

They recently released a new version of another product under severe deadline pressure and consciously decided to pick up a bit of short-term debt. As you can see, they’re already paying it back before it incurs too much “interest”:

Pc2

Prime Carrier project 2 over time

These are a great bunch of hard-nosed developers who are keeping the code-base clear of debt so they can focus on the principal – customer requirements.

 

Manage complexity like debt


Ben Hosking writes in Managing Complexity – The aim of Designing Code that:

The most important part of design is managing complexity

I like the simplicity of that. What happens if you don’t manage complexity. Well, it starts to cost. Talking at OOPSLA 2004, Ward Cunningham (Mr. Wiki) compared complexity with debt:

“Manage complexity like debt,” Cunningham told attendees. Using this analogy, he likened skipping designs to borrowing money; dealing with maintenance headaches like incurring interest payments; refactoring, which is improving the design of existing code, like repaying debt; and creating engineering policies like devising financial policies.

In an interview with Bill Venners (Artima), Andy Hunt (Pragmatic Programmer) extends the analogy concisely:

“But just like real debt, it doesn’t take much to get to the point where you can never pay it back, where you have so many problems you can never go back and address them.”

It’s a lovely metaphor. But it does breaks down in one place. Project managers don’t get a pile of bills through the door every month. Even if they wanted to, they can’t rip them open, sum them up, compare them against income and outgoings and discover just how fragged they are, or even hell, that they can afford loads more debt!

Well it’s not quite that bad. We can at least measure and sum up the complexity of items at different levels of design breakout (methods, classes, packages, subsystems and projects).  We may not be able to put a hard complexity number on the tipping point (insolvency), but we can give you a number. With this you can compare projects, monitor trends that show where it’s getting more or less complex, and discover which items at what level are causing the trend.

For example here is the home page for the Structure101 Tracker web application showing the sizes and over-complexity of several projects:

Tracker

Now, correlate XS with the depth of furrow on team leaders’ foreheads, and you’ve really got something to go on…

 

CAT-scan a code-base


Structure101 v2 goes beta today. With it you can walk through the code-base in slices from the class-level, to the package-level and up through the design levels, spotting tangles and seeing how far they have spread.

This is a snag of the Slice perspective with the slice selector highlighted:

Sliceselector

You can now see dependency graphs as matrices, which tend to be better for very large graphs (like slices). A value in a cell indicates a dependency from the column item to the row item. Here’s the equivallent of the tangle shown as a diagram above – as a matrix (highlighted) it now fits in on the screen:

Smallmatrix

And here is a much bigger slice of all the classes in the code-base grouped by parent package (the orange areas).

Bigmatrix

Even zoomed way out, it is possible to pick out some patterns on the matrix. The rows and columns are ordered so that as far as possible items only use items below or to the right, so any dots (dependencies) above the diagonal indicate cyclic dependencies. Horizontal lines indicate heavily used items, vertical lines indicate items that use a lot of other items.

Version 2 lets you “tag” (mark) code-level items (like methods and classes), and any higher-level item (like a package) that contains tagged items is shown as tagged. This lets you tag items in one slice and then see how it maps to other slices and hierarchies. For example, you could tag a big class-level tangle in the Slice perspective and then go to the Composition perspective to see how the tangle is distributed across the package design – it would look like this:

Taggedhierarchy

 

Gartner 2006 Technology Hype Cycle


The Gartner "Emerging Technologies Hype Cycle" is something worth giving a good once-over every year. The premise is that most technologies that eventually get traction will first go through a "Peak of Inflated Expectations" with lots of publicity and a lot of unsuccessful applications by the early adopters. This is followed by the "Trough of Disillusionment" (got to love these terms!) where the bad experiences cause bad press. The "Slope of Enlightenment" is a quiet period during which the technology is not much talked about, but experimentation continues and the best applications are discovered. Finally the implementations stabilize and the advantages become accepted during the "Plateau of Productivity".

There are 2 important aspects for a technology – where it is on the curve, and how fast it’s moving.

Here is this year’s:

2006_hype_curve

Get the full summary from Gartner here.

 

Recieve blogs by email


I happen to know that there exists people that have not yet set themselves up with a blog aggregator – mostly these are guys that already know everything, plus they haven’t lifted their noses out of their IDE since RSS was invented (hi Ian!). Luckily these guys have mostly discovered email, and now there’s R-Mail – just give it the RSS feed and your email and get your ass back to that late project already! I like this a lot. Rather than the pointless "hey, Ian, you should watch this blog", I can subscribe on his behalf and there’s no need for the "conversation".