Thursday, 24 July 2008

Regions

Does anyone use regions in their code?

Like many of the features in the .NET world that are not available in the Java world I’ve had to spend some time getting my head round them.

I think things like lambda expressions:

Html.ActionLink(c => c.Index())

and the single line getters & setters:

public string Name { get; set; }

are great language features. They, make our code neater, mean we can write less code and in the case of the lambda’s our code far easier and safer to refactor.

However, regions, I don’t get. To me they add zero value to the code we write, they are comments that allow our editors to arrange our code. Even one of the features of my much loved resharper will arrange code automatically putting it into regions… it’s one of the features I’m going to have to disable.

Anyway I read this blog entry earlier on and it hits the nail on the head for me.

http://www.codinghorror.com/blog/archives/001147.html

Saturday, 5 April 2008

code == data, jRuby rocks and ohh BTW i killed a villager

I'm just back form my first conference, Scotland on Rails (or I was when I started writing this blog entry... it's been a hectic week, believe me). It was great, that is to say I really enjoyed it. There was a diverse range of talks, from an experience report by first time speakers Richie McMahon & Maria Gutierrez to the innovative Edgecase dialogue from Jim Weirich and Joe O'Brien. So here is a my highlight reel.

Friday

Beautiful Code (Keynote) - Michael Koziarski

So this guy is a Rails developer, that is to say he is on the core team developing rails itself. He talked about some of the good and the bad code in Rails and, if I'm being honest, it was slightly out of reach for me. Having only developed one rails app to date my Ruby experience is still limited so when he talked about the good in alias_method I was kinda of confused. I get the idea, I am, by trade, sadly a Java developer and have used AOP so the whole idea of instrumenting a method adding before and/or after code isn't new to me. I did however see and understand the bad stuff. His example opened up ActiveRecord and showed the audience how Rails builds finder SQL, it is nasty. However it works well and is stable, but... it ain't pretty.

The conclusion he arrived at was good. In a nutshell he said that beautiful code is all well and good but ugly stable code that works is also good, because... well... it works and it's stable. He suggested that we, as developers, need to learn when to draw the line. When to say ok I'm done, that does what is supposed to do, now lets get on with some other task. I think that was a great thing to say. As a developers we need to know when to draw the line between beautiful code and code that can be understood, extended and ultimately be refactored to provide more functionality at a future date... but not now.

Pushing Rails onto our Stack: a system integration study. - Richie McMahon & Maria Gutierrez

This was an experience report about introducing Rails into an organisation who's productivity had slowed to a crawl because of, essentially, j2ee bloat. There were a few things about this talk that reminded me of my old pre bank work and I guess that is why it really hit home.

  1. The degree of pride that both Richie and Maria showed at their achievement. I thought that was cool and it made me really buy into the story they were telling. I knew where they were coming from. In the old job I had introduced, after years of banging my fist on the table, some Agile/XP principles; TDD, iterative development and stand up meetings. I felt passionate about that at the time and, I guess, to this day quite proud of what we did in that year.
  2. How Java frameworks slowed productivity. The same project that pioneered Agile methods pioneered the buy vs build approach in my last job. We stopped using home grown frameworks and proprietary code generators and started looking to the open source community. We came up with what had becoming a popular approach of Struts/Spring/Hibernate. Ohhh no!!! I can hear you all say with your convention over configuration hindsight, "that's XML hell". It was and I guess still is. We like Richie and Maria's team had made rapid progress in the early on then slowed under the weight of config... the interesting thing was though this happened over only 12 months.

Edgecase Dialogue - Jim Weirich and Joe O'Brien

So in a nutshell this was about mocking in tests, what should and shouldn't be mocked and what smells that can be identified by using mocks. Not that mocks aren't interesting but, the interesting thing about this was that it was, as the title suggests, a dialogue. You may be thinking OK, I know what you are going to say the dialogue was with the audience, you'd be wrong. The dialogue was between Jim and Joe. They literally acted out a day at work, pairing on some issues that Joe was having with his tests and using flexmock to solve all his problems. So apart from forming the opinion that only Americans would have the balls to pull something like that off and of the existence of flexmock I'm not sure I learned much here, which is surprising because I don't know much and these guys know loads!... we are also jmock crazy at work.

Code Generation: The Safety Scissors of Metaprogramming - Giles Bowkett

This was the highlight of Friday, maybe even the highlight of the whole conference. This guy is funny. Very funny. And clever... the git :) I'm not going to spoil it by giving my own terse summary I'm going to insist you watch it for yourself (or at least a version of it) and, as Giles says, read this book. What I will do is commit myself to a blog entry on code generation. It's a topic which has haunted me for a number of years. I have a love hate relationship with it.

So that was the highlights of Friday, or at least during the day. As expected the next stop after the conference was the pub. The drinking didn't stop till around one and in between the Scotland on Rails guys organised some pizza and a game of werewolf. The pizza was great, werewolf on the other hand... I just don't think it's my bag, saying that I was almost blam'd, and I do tend to be a little self concious when in the presence of uber geeks. Anyway, I did get a chance to be the werewolf and took great pleasure in killing the off Piers Cawley :)

Saturday

So Saturday stared with a greasy roll and a coffee, which I had to pour out in order to get in a Edinburgh taxi. Great start ehh!!

Domain Specific Languages: Molding Ruby - Joe O'Brien

Joe's talk was great and really explained what a DSL was. Interestingly Koz mentioned that he thought that the term DSL was being abused, not in Joe's talk however. He felt that a lot of so called DSL's he was seeing these days were just good OO code that modelled a domain. Piers added to that saying that code has to be in the language of the domain in order for us as developers to be able to clearly communicate with the customers. As a fan of DDD this was really good to hear. You can see an earlier incarnation of his talk here.

JRuby on Rails: Up And Running! - Charles Oliver Nutter, Thomas Enebo

JRuby rocks. It is of course just Ruby... maybe that's what the 'J' should stand for. But running it on the JVM has so many benefits. But this is why I like it:

  • It brings Rails deployment inside my comfort zone. This may sound like a really lazy thing to say and as I have never actually used fastcgi or Mongrel so I really don't have anything concrete to compare it against. But the thought of using a simple gem to produce a war file then dropping it into Tomcat sounds great to me.
  • Netbeans. Ok as a Java IDE it has for a long time been 3rd behind Intellij and Eclipse but as a Ruby IDE it's the best I've seen. Last year I played with a beta release for a few months and I loved it. It even kicks the pants off of the new Intellij 7 plugin, I'm gutted... I love IntelliJ.
  • Ruby gets compiled to bytecode on the fly when running on the JVM. You can even pre-compile it. This contributes to making it faster, almost 3 times faster, than using the CRuby interpreter. Fortunately, for you, this exceeds my geek threshold by a country mile so I can't even guess how this happens.

So that was it. I had a great time and learned loads, many thanks to Alan, Paul, Abdel and Graeme!

When does registration open for next year guys?

Monday, 3 March 2008

Recent events at No 53

Maisie:
  • started walking;
  • fell down the stairs;
  • named her teddy "babay".
Tom:
  • is now potty trained;
  • got his hair cut... with clippers, a no 4 (on the sides only);
  • is really getting the hang of his scooter.
Jules:
  • is facebook mad;
  • is going to run the 10k.
Me:

Monday, 4 February 2008

The right side of the tracks

Scotland on Rails is on it's way!! Sponsorship looks like it's flooding in and there is a great list of speakers with a diverse range of topics. Big it up to Alan, Paul and the guys.

Sunday, 21 October 2007

Flame bait

I bumped into one of my former project managers a few months back. We talked a little about how things were going on the old project (which by all accounts goes live tomorrow... 3 years and 7 months late) and how things were for me in my new position. I told him a bit about XP and how much I enjoyed it. He seemed rather sceptical about how it could be costed. A couple of days later I came across this article and forwarded it to him.

Sometime later he replied. Part of his reply was, as he put it, "a bit controversial to stimulate the debate". After a few days of thought and few weeks of procrastination I replied, here it is:


PM: The Current Climate – the software industry does not have a good track record in delivering large projects. Therefore, customers are very nervous about entering into what they see as an open ended contract. From experience, it is very difficult to secure funding when you can’t guarantee what will be delivered at the end or when.

Having spent most of my IT career in the public sector I had no reply to this. I suppose I could have argued the "what will be delivered at the end" saying that a customer would get exactly what the customer wants and needs, but I guess his point was about funding.

PM: Design – the agile approach assumes an ongoing design process. The software industry is pretty unique in this regard. In most other industries (eg construction), no-one would contemplate starting a project without a completed design……why should software be any different? I have bitter experience of developers having to re-factor code (which really meant rip it up and start again) because module x no longer worked with the new architecture.

Me: Please tell me you aren't trying to compare the job of a programmer to a brick layer? The waterfall approach of Big Design Up Front has been almost completely discounted by the agilists. The reason I see for this reaction is that, at a detailed level it's almost impossible to fully understand every eventuality/path through a software system. If you were to try to envisage and document every scenario, my guess is that you would have spent as much (if not more) time than it would have taken to develop a working system. Not a complete working system that meets all of their business needs, but one that could meet their most critical business needs earlier and could be put into production and be of value.

Another major issue (which ties back to your earlier point) is that customers don’t know what they want, especially not from a large system and they can’t be expected to. They are the best people to understand the domain problem they have of course, but not the best solution that solves that problem especially not upfront. That’s why designing and implementing a large system before letting a customer use it is why, I guess, the software industry has a bad reputation.

As for refactoring, it is about refining code to: increase quality; re-useability; maintainability; simplicity; etc, all of the things that reduce bugs, please customers and make applications easier and cheaper to maintain and modify going forward. Refactorings like you suggest, where large steps are taken to rewrite areas of code, occur when the processes of incremental design and refactoring are not put in place.

PM: Quality – the quality argument in the article seemed to skip over the fact that a bad programmer is a bad programmer no matter what methodology you use. The article (and fans of agile programming) suggests that agile programming is the panacea and will solve all the quality problems….garbage! At the end of the day, the customer still has to have a working system (i.e., bug-free).

Me: A bad programmer is a bad programmer I agree. But with techniques like test driven development (TDD) and pair programming a bad programmer can become a better programmer (I won’t go as far to say a good programmer). But a bad programmer who understands and practices TDD, commits code regularly to a code base which has automated continuous integration can produce reliable code. Where as a bad programmer left on there own without writing tests first can end up in a spaghetti junction of bad code with no way of verifying the quality of their work. Either way good or bad programmers who don’t write tests first can write code that’s buggy.

I agree that Agile development methods aren’t a panacea to bug free code, good developers play a big part. But I do honestly believe that projects benefit massively with agile techniques like:

  • TDD;
  • Refactoring;
  • Continuous integration;
  • Pair programming;
  • Short development iterations;
  • Daily stand up meetings.
They increase:
  • Code quality;
  • Understanding of requirements;
  • Understanding of a code base throughout a team, which for one helps reduce risk when team members move on;
  • Communication both internally and externally.

Friday, 17 August 2007

My worst interview

Q: So tell me the difference between Statement, PreparedStatement, and CallableStatement and when you’d use each.
A: Um, you use a Statement to perform a query from a database.

http://burtbeckwith.com/blog/?p=44

Minus the ridiculous number of buzzwords on the CV, this could have been an interview I attended 3 years ago. I had a howler!! TBH I was a bit green back then and the interview was a wake up call.