The half life of a project
The half-life of a radioactive substance is the time required for half of a sample to undergo radioactive decay.
en.wikipedia.org/wiki/Halflife
Scott Bellware is talking about the rate of decay of the maintainability of a project.
The rate of decay of maintainability is the measure of how fast your maintainable code looses it's maintainability after your agile development guru or consultant moves on to another project.
This is a subject of a particular concern of mine, since I was often accused of building software that only I could work with. I am currently teaching an MSPD course with the express purpose of grokking the way that the average developers go about their work. It has given me a lot of insight into why Microsoft does some things (and I still vehemently disagree with the decision).
I taught data access approach using With and anonymous delegates:
With.Transaction(delegate(SqlCommand cmd) { cmd.CommandText = "SELECT COUNT(*) FORM Customers"; return (int)cmd.ExecuteScalar(); });
This is for people who learned C# as part of the course. It works, and while this is not something that they are likely to build on their own, once you set up the infrastructure and explain how it works, there weren't particular issues with this.
The crux of Scott's post is this statement:
The keystone of intentional maintainability, nestled in the slot at the apex of an arch of XP practices, is code that is instantly understandable by the folks who have to do the maintenance.
That is an argument that I have had with quite a few people, quite often. Because the problem is with the definition of "the folks who have to do the maintenance". At one time, I had a... discussion with someone that thought that they can hire someone off the street (purposefully low level, to keep costs down) and have them start working on a big (10 months of continuous development) project from day 1.
That meant, as far as they were concerned, that we were to use only the "standard" approaches, so we wouldn't break the wizards and make the application "unmaintainable". That is not maintainable in my book, quite the opposite, frankly.
From my point of view, an application is maintainable if I can take someone of the street, give them the overall view of how things work, walk them through a use case or two, and then set them on the code on their own.
This method belongs to the LoginController, and I am going to assume that it is going to be instantly understandable my most people who can read code. But, and this is important, it is not maintainable unless you figure out what is going on all around it.
/// <summary> /// Authenticates the specified user, will redirect to the destination page /// if the login is successful. /// </summary> /// <remarks> /// If the login is not successful, additional information may be found on: /// Scope.Flash[Constants.ErrorMessage] /// </remarks> /// <param name="user">The user.</param> /// <param name="password">The password.</param> /// <returns>True if the user has authenticated successfully, false otherwise</returns> public virtual bool Authenticate(string user, string pass word) { bool isValidLogin = authenticationService.IsValidLogin(user, password); if (isValidLogin) { Usage.SuccessfulLogin(user); string returnUrl = Scope.Input[Constants.ReturnUrl]; if (!string.IsNullOrEmpty(returnUrl)) Context.AuthenticateAndRedirect(returnUrl, user); else Context.AuthenticateAndRedirect(Settings.Default.HomePageUrl, user); return true; } Usage.FailedLogin(user); Context.SignOut(); Scope.ErrorMessage = Resources.BadUserOrPassword; return false; }
I think that I have done a moderately good job in making my recent projects maintainable without me, and I am trying to make sure that there won't be many cases of "This is Oren's CodeTM, I can't touch that". We aren't there yet, but we are getting there. Another developer is going to take over a project that I have led, and I have confidence that after the initial panic, things would settle down.
My criteria for maintainability if that if you know X, Y and Z (usually technologies that I use in the project, mainly NHibernate), you should be able to get everything from the code.
Then again, my current project's Guide to the New Developer does have two pages dedicated to dependencies and links to the documentation...
Comments
"This is a subject of a particular concern of mine, since I was often accused of building software that only I could work with."
I hear this often, and so after some introspection to make sure that I haven't actually created a very expensive pile of spaghetti, take it as a compliment.
Things that I do that 'only I can work with', in no particular order:
Use a config file
Use ORMs... apparently only the brightest amongst our species can grasp the cosmic mysteries of NHibernate.
Use any reflection whatsoever
in relation to that, create custom Attributes
Solve a problem with anything that resembles a provider, adapter, or similiar GoF-type pattern
Cheers!
@Nick,
That's depressing and no fun at all. ;-)
Frankly I'd rather assume that all bets are off insofar as maintainability is concerned if the new maintainers lack access to the appropriate level of sophistication to actually participate meaningfully in the design of the system.
Software maintenance requires more skill than just greasing the gears. If the new maintainers are monkeys, then at best we can hope they won't throw a wrench in the works. We shouldn't be too surprised if they poop all over the machine.
Investing in maintainability is completely different from investing in agility. The former has a much lower bar for quality than the latter. Any old piece of kludgy software can be maintained by most anyone (begrudgingly) if the stakes are high enough. But agility quickly evaporates as soon as the software is neglected and suffered to gather dust.
As software engineers, we should be so happy as to ensure that our legacy is one of mild puzzlement or even awe (!) rather than curses...
@Oren: You wrote: "... someone that thought that they can hire someone off the street (purposefully low level, to keep costs down) and have them start working on a big (10 months of continuous development) project from day 1." [...]
"... give them the overall view of how things work, walk them through a use case or two, and then set them on the code on their own."
Don't you do pair programming? :)
@Jeff: "Investing in maintainability is completely different from investing in agility." "Agility" in code? Is that not part of maintainability? I would think that they are but (as you say) only to differing extents. However, maintainability - to me - is the wide concepts that encompasses all others. Do I make sense?
Mawi,
Not in this instance.
This is a finished application where I am talking about the hand-off procedure
Comment preview