Comments vs Readable Code

Posted by Kat Crichton Tue, 29 Dec 2009 16:51:00 GMT

There is a widely contested mantra of Extreme Programming that says that comments are superfluous. Inaccurate and often out-of-date meta-information just makes your self-describing code and accompanying tests harder to read and understand.

However the opposite can seem to be true; how often do we try to decipher unpleasant code that has no comments because the mantra said that they were “evil”? It is dogma that leads to this problem.

It is important to remember that “no comments” is mantra not dogma.

Dogma is authoritative and not to be disputed, doubted or diverged from. That doesn’t sound at all agile to me. The word mantra originates in Sanskrit meaning “tool of thinking” or alternatively “liberation of thought”.

Dogma forces you to stick to practices that are believed to be good for you. Mantra can help you to re-evaluate your practices to find those that are actually good for you.

When you come to the point where you feel compelled to write a comment, think hard about whether or not it’s really necessary;
  • Could I convey this comment by renaming a method or variable to something meaningful?
  • Could the accompanying unit test describe the code better?
Can’t think of a good name for a class or method? Okay, sometimes higher level architectural structures need to be documented, right?...
  • Maybe the class that manages the high-level architectural pattern could be better named?
  • Is a complex high-level architecture really giving you the required benefit if it is not easily understood?

Personally I cannot get to the end of these options without recognising ways of improving my code, although sometimes I’ve added comments to help me understand a large amount of ugly code, prior to refactoring.

The trick is to just keep thinking. Process is never an alternative to thought.

Posted in  | 1 comment

Rails IDEs

Posted by Kat Crichton Fri, 11 Jul 2008 15:53:00 GMT

I use Ruby-on-Rails to develop my own sites. It also makes up the majority of the projects that I am involved in at work. I will happily sing its praises and there’s no other language I’d prefer to be writing code in at the moment.

Our other Web applications are written in Java, so our IDE of choice is Eclipse. It’s a fantasticly fully featured open source IDE that is also a development platform if you care to use it as such.

Until the end of 2007 we were using and watching the progress of a couple of Ruby and Rails plugins for Eclipse called Ruby Developent Tools and RadRails. These Ruby development some of the same tools that graced the Java developement environment in Eclipse.

Sadly though, another larger Eclipse plugin vendor called Aptana made the developers of each of the existing tools an offer they couldn’t refuse. RadRails and RDT were absorbed into the monolithic Aptana plugin.

Aptana is downloadable as either a standalone application or as an Eclipse plugin. It has various versions that include Jaxer (an AJAX server), tools for developing against the Apple iPhone and Adobe’s AIR platform.

I have nothing against large applications as long as they are well written – although I would state a preference for the small is beautiful philosophy.

Unfortunately, since installation of Aptana, our Eclipse based development machines run like dogs and crash all the time. Evenutally after having to kill the eclipse process time after time, some corruption creeps into one of the plugin files and Eclipse will no longer start up. We then start the process of removing, downloading and reinstalling 79MB of Aptana plugin that can only be installed using the automatic update site.

The ruby/rails plugins are the best that we’ve found, allowing us to visually debug rails applications, run tests and browse our applications intelligently, but at the moment they’re wasting so much of our time that we’re seriously considering going back to a plain text editor.

Posted in ,  | Tags , , , ,  | no comments

Gorgeous Day

Posted by Kat Crichton Fri, 02 Nov 2007 14:15:00 GMT

The weather is stunning. It's November and we've been sitting outside the local pub in tee-shirts, enjoying the autumn colours. There's nothing quite like a nice Friday lunchtime with work colleagues and some good food and drink.

The conversation flitted over T3's DIY efforts (We have many Tims), including a partial loft convertion. Very impressive. We're thinking of converting our loft and it'll cost at least 20 grand. T3 seems to have achieved the same in just over a thousand quid! Food for thought, although we are planning to get a full staircase put in, which will be the majority of the cost.

Other reasons for jollity include the fact that we have achieved our commitment for this iteration and that we included an afternoon of ''Innovation'' for exploring non-purchase-order based ideas. It's all a bit Google and I can only hope that it continues along similar lines in the future.

Posted in , ,  | Tags  | no comments

Ram-BO: New Blood Part II

Posted by Kat Crichton Sun, 20 Aug 2006 18:59:00 GMT

Which brings me unpleasantly to something touched upon in the white book...

When pairing, it is essential to maintain a level of personal hygiene that befits the process of sitting very close to another developer for the whole day.

So far one half of our new recruits has proved to be somewhat less than satisfactory in this area. It's hard to know - as an Englishman and a gentleman - quite how to breach the subject, but breach it I must.

I have slightly more confidence in my point of view as I've had this opinion shared by a long standing colleague.

The drinking, however, is not within the scope of my interest, having not as yet had a detrimental effect on any project that I have a current interest in. These things are often over-emphasised in our company, since the drunken antics (several years ago) of one former employee.

Anyhow, three months probation should be sufficient to determine the validity of our choices.

I wish them both the best of good luck.

Posted in ,  | Tags , ,  | no comments

New Blood Part I

Posted by Kat Crichton Sun, 20 Aug 2006 18:47:00 GMT

It's hard work breaking in new recruits. I've had a sore throat all week from trying to justify our existing code-base and customer relationships.

As hoped, the new blood is having an almost immediate positive effect. Irritations that had faded into background noise have been brought to the fore.

Someone without the tarnish of several years on the frontline can much easier see the atrocities that are committed in the name of Truth, Justice and the Extreme Way. Not that any blame should be attributed to XP - just to our slow deviation from the path of the righteous.

Posted in ,  | no comments

New Blood and Motivation

Posted by Kat Crichton Tue, 06 Jun 2006 11:47:00 GMT

Our XP team is distinctly low on developers at the moment. We're down to five from twelve earlier in the year. The backlog of stories is constantly growing as the team just doesn't have the bandwidth. The extra pressure may be partly responsible for pushing good people out of the company.

It seems that any team looses motivation without a transfusion of new blood, even though years of team experience should create a much more capable entity.

The remaining developers have all been with the company for 5+ years which creates a more cynical atmosphere than usual. New blood brings with it enthusiasm untainted by previous business mistakes, which blends well with experience gained by learning from those mistakes.

The small team size also means that we don't have variety of skills and enthusiasm. Specific jobs cannot be handled by people with a preference for that type of work, so boredom sets in.

The good news is that we're recruiting heavily now and will hopefully soon have some of the necessary claret. It's up to us to make the team successful again.

Posted in ,  | no comments

Back on Line

Posted by Kat Crichton Tue, 28 Feb 2006 18:45:00 GMT

Phew! My ISP upgraded to Rails 1.0, which knocked the version of Typo I've been using for six. I probably ought to put the correct version of Rails into the vendor folder to stop it happening again.

I decided to start using the Subversion release. I normally wouldn't trust code that's non-release, but since Typo seems to be written test first, I have a lot more confidence in it's ability to stay unbroken by new code.

Anyway, after some struggle converting my old data into the new format - including trouble installing MySQL Server 4, I'm up and running again.

Posted in ,  | Tags , ,  | no comments

XPday5

Posted by Kat Crichton Wed, 30 Nov 2005 06:28:00 GMT

Just got back from XPday5 where my colleague Dafydd Rees and I presented a talk on Rails for Real. It seems to have gone down well and a lot of delegates were interested in learning more about our experiences using Ruby-on-Rails for a major project.

I very nearly didn't make it up to London at all having contracted a nasty stomach bug or flu at the weekend, which returned shortly after the talk. Thankfully adrenalin kicked in for the duration.

Posted in , ,  | 1 comment