Archive for the ‘Project management’ Category

TDD, evolution and architecture

Sunday, November 15th, 2009

TDD has had a rollercoaster ride since Kent Beck first coined the term in 2002. This is nothing to wonder about – TDD really has the power to be a significant power for change for a team of developers.

There are basically two camps, who don’t agree 100% on what the last “D” is. Kent Beck originally called it “Test Driven Design”, making the tests an integral part of the design process. More than half the people I talk to today (counting myself) is having a problem not calling it “Test Driven Development”, where the tests are not as strong a design driver.

Today, I am going to write about the “tests provide good design” camp. I am in good company, too. Uncle Bob and James Coplien have both debated this, along with many, many others. I am now going to weigh in on this, too. What arrogance. Oh, well. Here goes:

TDD, in the original meaning of the acronym, is a technique where tests are written first. Since the test is new, it will fail. The minimum amount of code that will make the test run is then written, and the process is repeated. At some point, the developer may decide to clean the code up, in which case the tests must run successfully both before and after the cleanup. This refactoring of the code gradually improves the quality and the architecture of the solution.

Testing the wrong thing

A couple of weeks ago I was told that a team had testing well in hand. They had 97% test coverage. I immediately became very, very skeptical since I know the bug count for this team.

We developers are techies. This is what enables us to create very good applications. It is also one of our biggest blind sides. We tend to treat everything as a technological problem. If this is transferred to testing, we get nonsensical tests with names like “testConstructor”.

This is a really, really big problem. Your customer is never going to care about your constructors. What he cares about is the behavior he expects from the solution. This kind of problem was described by Dan North when he coined the term BDD, where the tests are explicitly modeled on customer-oriented statements. So – tests should test something the customer cares about, not the implementation. We may want to change the implementation in the future.

Your tests should be connected to your business model

A side effect of the above statement is that you, if you are using DDD (Domain-driven design, are going to have tests that nestle up to your domain model very intimately. Your customer is going to use some nouns, those nouns are going to become parts of the model, and your tests will probably express themselves using the same nouns. It is imperative that your tests can handle changes to the “domain language” your customer is using.

The weakness of refactoring

Refactoring is a process where you improve your system by getting your tests running right before and after you make a nonfunctional improvement. The first book I saw on the subject was by Martin Fowler. I recommend this book heartily to anyone who hasn’t heard of the term before. Since TDD makes heavy use of refactoring, it is important to understand the limitations of refactoring.

I really hate the “refactoring” menus in IDEs. This is not refactoring, in the meaning Fowler used. These are automatic transformations of your code, and disconnected from your test cases. This tool is on a lower level than refactoring is.

Refactoring can only help you make changes in situations where you have tests that cover the behavior that is affected by the code you want to touch. There are lots of implications to this simple statement, but the most important one is that you cannot change the interfaces your tests use using refactoring. You would need to change your tests too, which would place the operation you are undertaking squarely outside of the “refactoring” paradigm. Tool support may help reduce the risk of the change, but the change is not a refactoring operation.

I know lots of very competent developers who are trying for tests that have sub-second runtimes, which means they are usually unit tests where large parts of the application has been disabled. The danger inherent in this approach is that your test boundaries should be very carefully chosen – and should not evolve significantly. A sub-second test runtime is nice, but is not a requirement the customer necessarily cares about if it costs him significantly along some other dimension.

Creating APIs is something developers think of as fun – and it is. This does not mean your application should be littered with hundreds of shoddily designed APIs. Keep the interfaces you expose (to tests or other clients) to a minimum. This is necessary since these bits cannot be allowed to change very often.

I think tests should be running against a system that is as close to the finished architecture as possible, and test against fairly large functional areas. These areas will become your “published” APIs.

Evolution of architecture

TDD in its pure form is an evolutionary process where the developer decides which code structure is the “fittest”. He uses the microscope created by his test suite to do this.

As I have already mentioned here, I have just finished reading “The greatest show on earth” by Richard Dawkins. He devotes a whole chapter to the design shortcomings of evolution. In his case it is a rebuttal of creationist theories, but I am going to pinch his argument here to point out the known problems to trying to evolve an architecture.

On page 360, I found the following paragraph:

During the evolution of the mammals, however, the neck stretched (fish don’t have necks) and the gills disappeared, some of them turning into useful things such as the thyroid and parathyroid glands, and the various other bits and pieces that combine to form the larynx. Those other useful things, including the parts of the larynx, received the blood supply and their nerve connections from the evolutionary descendants of the blood vessels and the nerves that, once upon a time, served the gills in orderly sequence. As the ancestors of mammals evolved further and further away from their fish ancestors, nerves and blood vessels found themselves pulled and stretched in puzzling directions, which distorted their spatial relations one to another. The vertebrate chest and neck became a mess, unlike the tidy symmetrical, serial repetitiveness of fish gills. And the recurrent laryngeal nerve became more than ordinarily exaggerated casualties of this distortion.

Again – go read this book!

So – the recurrent laryngeal nerve. What am I on about? Well, this is a nerve that is routed from the brain, down into the chest to hook around a major blood vessel, then to return to the larynx. An engineer would lop it off and reroute it to save several metres of nerve in the case of a giraffe, but this is something that we cannot completely trust evolutionary strategies to do.

Ok, what is the solution?

I believe in self-organizing teams where there are incentives to choose the best designer to go off and design the APIs that need to be good from the beginning. I believe in using tests to help get the rest of the design good enough.

This won’t help much, though. Some teams are not heavy on design expertise, or worse yet, may think they are. I have had colleagues with two years of work experience refer to their extensive experience while talking to people with double-digit career spans. I am sure I did it myself ten years ago, and I don’t think there is a single developer out there who is not overestimating his knowledge in one or more areas. Teams who could use more design expertise should do their design up front, or at least to find the parts of the solution which needs to change.

Other teams are able to get things right straight away because most of the teams are experienced designers. If your team has multiple Kent Becks on board, the best thing for an architect to do is probably to shut up and let them get on with it.

There is absolutely nothing I can say from this end to help find this balance, since the balance is team specific. But if you are a person who in some way or other has an interest in the ability of a team to deliver change and quality fast, I suggest you make sure they get a steady stream of domain model changes – and measure them on their ability to get things into production. That way, you will always know what to expect in terms of speed of change.

If they get it wrong – let them stop and sort it out.

If they suggest not releasing to production as often (it is too costly!), get outside help! Your team is in effect telling you they can’t cope, and the problem may be you.

Agile projects don’t need architects?

Saturday, November 7th, 2009

The past couple of days, people have talked to me about architects. There are a couple of statements I have heard:

- agilists don’t do design

- we (my architect team) are supposed to work as a team with the developers as a self-organizing team. How can we do that, and still tell the teams that they need to do something differently?

This is all based on a couple of misunderstandings, I think. I will try to straighten them out here.

“Self-organizing teams can decide everything by themselves”. This is obviously wrong. If this is the case, then what is the product owner for? The team decides how to make something, but not what to make.

Mike Cohn wrote someting about this yesterday on his blog. There is obviously at least one proponent of agile – with a proven track record – who also thinks about up-front design, which means the teams around him are not all reactive. YAGNI, but you just might want to think about things for a bit anyway.

The product owner is one thing. Something similar applies to the scrummaster or the agile coach. People seem to think these characters don’t wield any power. This is also bunk. The scrummaster controls the direction of the team, almost in a tayloresque. The major difference is that the team is allowed to set their own pace. The same thing applies to the scrum coach – whoever thinks coaches have no influence is obviously not one.

I have to admit I am not a purist. I think there is a need to have a technical function – something like a product owner – to handle technical alignment and nonfunctional stuff at the system level in large projects. I don’t really care what this character is called as long as both the development teams and whoever is exercising the function are in agreement on what this function can and cannot do. I will continue to call the function “architect”, even if this will lose me some hardcore agilists.

Whoever is in a function like this should take care not to become just another developer. This is the first mistake any developer who is tasked with a different job makes. Once the problems start cropping up, it is very easy to fall back into the job you know how to do. I have seen this happen many times – and I did it myself, back when I started out as an architect/techie. The primary task of an architect is to ensure the teams are aligned. Life will become hard if this task is left unfulfilled.

This is where life gets hard. I don’t believe it is possible to get this technical alignment to happen without being a hardcore techie. I absolutely abhor non-developer architects. Still, I am saying techies who get this kind of mandate need to keep at least partly away from being a developer. Feel conflicted yet? You should. This is a very hard balancing act, which is compounded when teams do not agree and there is a need to be a part of all teams and none to be able to get things moving forward.

A coach achieves this by actively not delivering opinions. There are several ways of trying to handle this conflict, ranging from becoming “an opinionated asshole” who never delivers anything of value, going for the more military imperative style, through a coach-like style. Not everyone can adopt all of these styles, and I am not sure any of these styles are right in all situations either. Most architects lack psychology knowledge, and are ill-equipped to do their task.

I am reading “the greatest show on earth” by Richard Dawkins. On page 217, he muses on the building of cathedrals in the context of evolution:

An architect designs a great cathedral. Then, through a hierarchical chain of command, the building operation is broken down into separate departments, which break it down further into sub-departments, and so on until instructions are finally handed out to individual masons, carpenters and glaziers, who go to work until the cathedral is built, looking pretty much like the architect’s original drawing. That’s top-down design.

Bottom-up design works completely differently. I never believed this, but there used to be a myth that some of the finest medieval cathedrals in Europe had no architect. Nobody designed the cathedral. Each mason and carpenter would busy himself, in his own skilled way, with his own little corner of the building, paying scant attention to what the others were doing and no attention to any overall plan. Somehow, out of such anarchy, a cathedral would emerge. If that really happened, it would be bottom-up architecture. Notwithstanding the myth, it surely didn’t happen like that for cathedrals. (Footnote: My medieval historian colleague Dr. Christopher Tyerman confirms that this was indeed a myth that was invented in victorian times for idealistic reasons, but that there was never a scintilla of truth in it.)

This is a wonderful book – go read it.

So, it seems that our profession is now creating the same myth that was created a long time ago by (parts of?) the building industry. I am guessing whoever built cathedrals in victorian times did not perpetuate this myth, but builders of smaller things – things requiring architecture that could easily be handled by a small handful of people – could have used this myth to cut the architects out of the loop. You can still buy a small house without getting help from an architect. I wonder if there are any failed cathedral projects out there where a bunch of masons went wild?

Our problem is that the development business is very new. We don’t know how to define an architect role in a way that works yet, and we don’t know when we need to have this role around. I have a hunch that most who get this right are doing what they are doing by the seat of their pants.

I would also guess the definition of what a software architect should do is situation-dependent. Some teams produce useful installation instructions without being prompted. Others are completely at a loss and need a bit of guidance. Some teams are whipped into stopping their QA processes in favour of producing more functionality, and are never allowed the time to correct the shortcoming.

My own shortlist of candidate areas for guidance is:
- System-level QA
- Performance
- Versioning
- Deployment
- Technology platform (as in “all subsystems should use the same OS and middleware to reduce operating costs”, not “use junit 4.3.1″)
- Arbitration of interfacing conflicts
- Tracking of delivery by external parties, if applicable
- Moderation of time-to-market demands by showing the cost of skimping on structural quality
- Establishing an expectation of the lifespan of the software

I am writing an architecture mandate right now, where I am trying to find the balance between owning nonfunctional requirements, letting the teams be agile (or not, if that takes their fancy), and still opening the door for support if they need and/or want it. If I go too far in one direction, the mandate turns into a big ball of mud which won’t help anyone. If I go too far in the other direction, there won’t be room for change if there turns out to be a need for it. I am going to try to get reviews of the mandate every three months to try to get the whole thing right.

If you have any thoughts on this, please feel free to leave a comment.

X is dead. Long live X.

Monday, October 19th, 2009

The last couple of weeks, there has been a flurry of “X is dead” blog posts. Have your pick: Java, ORM and a lot of other things have been declared dead. Rest in peace. Pushing up the daisies. There is a new technology on the block now.

The inevitable answers are usually not far behind. X is not dead after all. You insensitive clods. And I happen to think the coffin should be black, thank you.

I wish people would take half a step back. Yes, technologies become outdated. Then they die, or linger on, doomed to a Cobol-esque existence in projects without the funding and need to evolve. Get over it. The new technologies will also become obsolete, I guarantee it. Struts is now uncool. I can remember how nice it seemed when it appeared.

The interesting question is how your project can get rid of “dead” technologies, which usually means technologies that are now “uncool” because the in-crowd are not using them any more. Can you do that in your projects? What technologies can you swap out for something different? How often would you want to do that? What would the costs and the benefits be? How can you reduce the costs of getting a project to become dynamic and less technology-bound?

Ave artis nova, simili artis seneca.

Intelligence and hiring practices

Sunday, October 18th, 2009

I found a weekly in my mother-in-law’s flat today, with a relatively long article on intelligence (good), and why having an IQ of 180 didn’t necessarily mean you were able to get a good job (presumably bad, depending on your definition of “good”).

I started interviewing potential developers for positions around six years ago. Since then, I have seen a lot of resumes, and I have talked with a lot of people. The reason why I am writing this is that a friend of mine, who is a top-notch developer without any managerial experience told me he envied me because I have an insight into how an interview works from the employer side. Most people tend to get this wrong, so I will try to explain how my head is bolted together when interviewing. Hopefully, other people will think the same way.

Norwegian schools and intelligence

The backbone of the article I referred to seemed to be an assumption that very smart people get bored in the norwegian school system, and that Mensa is a kind of support group for the poor people who are cursed with an above average intelligence. There were quotes along these lines, at least, but I will try not to tar all members of Mensa with the same brush. The idea was that school work was so ridiculously easy that being interested in it was a bit beneath these people.

When I was at university, we had to jump through a number of hoops in order to graduate. Some of these hoops were knowledge-based (I remember a course called MA-105 with fondness). These courses were designed to be harder than adequate, prompting most students to have some thoughts about whether they wanted to go through with their studies, or to find something else to spend their time on.

The other kind of test put into the coursework was a test of willpower. Many students spent a lot of time finishing their M.Sc. thesis. Part of the reason was that the earlier grade of Cand. Real. was twice as long, and faculty had not completely caught up with this fact. Another reason was that students were mostly left to their own devices. Finishing the thesis was a different kind of filter. If you hired one of these people, you knew that you were getting a reasonably smart person with a will towards doing something.

Keeping students around indefinitely is a costly proposition, so these studies have now been restructured to provide much more guidance, forcing the students through the system faster. The downside is that candidates have not been sieved the same way as they were before. Employers have had to compensate for this.

This is why I think there is a broken premise in the article I read. The article is based on the premise that extremely intelligent people can do whatever they want. This is garbage. Intelligence is only one part of the equation. There are persons out there who are both highly intelligent and simultaneously too lazy to work at something for a significant amount of time. I don’t believe there is any connection between these two personality traits.

What does this mean for my interview?

There are literally thousands of pages out there explaining how to put a sensible CV together. The goal of these pages is to get you to an interview. From there on out, you are on your own. What happens in the interview is mostly a private affair.

Putting a good CV together is a very, very important task. It is not common for senior developers to read through 250 CVs. The contents of the CV is the first toll gate that gets you closer to an interview. If an employer gets 250 CVs, only three or four people get an interview. The other 245 people are – hopefully – not right for the job.

Sometimes, the sieving process means your CV will not get read. A local employer is known to have divided a bunch of CVs in two, binning one half while saying that he didn’t need unlucky employees. In other words, not getting an interview does not mean you are unsuitable. You may just be unlucky.

There are ways to grab attention. A girl who was applying for a position five years back tried to bribe her way into an interview by offering a hot balloon ride. It was all done with humour, and I still remember the CV to this day since she managed to tickle my interest. This is a bit dangerous since it depends on the interviewer sharing the same kind of humour as the candidate. Oh, and by the way, she didn’t get an interview, and I didn’t get a balloon ride, but it was a very close call.

Another guy in the same bunch of CVs was not that lucky. I was given a 5 cm wad of CVs. About 25% of that thickness turned out to be one CV. This bloke had added copies of everything – even a copy of his boy scout knots award. I also remember this CV for much the same reason – it gave me a laugh, even if it was more of an exasperated one.

The final CV I want to mention is the electrician with a six week course in building PCs who applied for a senior developer position. Take care to understand what the position is, and don’t apply if you are clearly not eligible. You will be seen as a time waster.

I will look at your positions, I will look at the technologies you claim to know. I will have a look at your cover letter – if you say you are interested in switching pastures, I may still have room for you. The ones I think best match the skill set I need, who will be willing to work for the money I have, and who seems to fit socially with the team I want to build will get the interview. It is that simple, and that hard. Prospective employees usually have no idea how I want my team to be built.

There are other ways to get my attention. If you know someone I trust, you should get them to give you an introduction. If the introduction is good and I have good experiences with referrals from this person, you will almost certainly get an interview.

So, let us say you have been able to get an interview. Now what?

Time for the interview

Norwegians are usually an informal lot. I usually wear a sweater, t-shirt and jeans to work. I may wear a suit if I feel like it, but I usually don’t. It would not be playing the part of techie hereabouts. I want you as a candidate to dress much the same as I do, but a little neater. Business casual is good. A three-piece suit will earn you a couple of questions to try to figure out what is happening. Turning up smelling of sweat, and possibly stale beer, is a surefire way of losing the interview on the spot. Talks with employees about the need for personal hygiene are not experiences I cherish.

When the time comes to meet, we will probably meet on neutral ground, which means the reception or somewhere like it. I will offer you coffee, water or something else, and try to put you at your ease. If you are very nervous, skip the coffee and take water instead. When you are in the meeting, try not to use your mug or glass of water as a lifeline. Many people – myself included – grab onto something for comfort when they are under pressure. That is all fine, but you may be holding onto the cup when you should have been pulling out some paper to draw something for me.

Most people are very, very nervous. There is no need to be. My job is not to kill or maim. My job is to find out if we should work together. I really won’t bite. So try to relax, yeah?

There are two ways we might start. If nobody has done it before, I will present the company and what it does. If someone else has already done that, I will pare it down, and just describe myself and what I do.

I think there are two ways the remainder of the interview can work out. If you are talking to a senior techie who has lost his touch, and is willing to do full-time administration, you will probably breeze through the interview. I would ask myself if I really wanted to work for an architect like that.

The why…

Now, here is a dirty little secret: I don’t care if you know the contract of the equals method in the java Object class. I may ask, but the contract is not the endgame. You can look the contract up if you need it. My goal is to get you talking about contracts, equality, possibly cross-references to Haskell, ruminations on how hard it is to implement equals, why you are fed up with ORM, have I tried the new eclipse plugin that does this, that or the other, …

The details are not interesting. When I ask someone why they prefer to develop on Ubuntu, I don’t care about their reasons. I care about the reasoning that lead them to the decision. A developer who says he prefers jetty over tomcat probably has some reason for it – even if the reason only is that he has never seen a reason to fix something that works, and haven’t been able to prioritize toying with other containers. I want you to show me that you are not just parroting what other people are doing, but that you understand the reasons behind what you do.

The how…

I will probably also ask quite intricate questions about stuff you say you are proficient with. Sadly, the term “expert” is very variable. “Expert” from one CV means beginner-level, while another CV might hide world-class knowledge. I have had people claiming to know unix well not be able to tell me what services were running on one of my boxes. I need to know this stuff in order to map your skill set against my expectations, but it doesn’t mean much either way. Competent people are able to pick up technology fast. I will need to know if you need teaching.

I will also try to figure out how you learn. Do you read books? Blogs? Go to conferences? Do you participate in something that gives you knowledge? What do you do on your time off? For norwegians – are you comfortable reading english books? Speaking english? How about italian?

… and how it all works together

There is still a relatively large amount of developers out there who do code-and-fix. I need to know how structured and disciplined you are. I will try to draw you out on this, and you should let me. Most of the people I interview have absolutely no idea how their code production process works. How do you handle bugs? Have you got any personal little quality improvement procedurettes you use? How many years were your projects meant to live?

All of this goes towards giving me an idea of how structured you are. I think this is much more important than knowing technologies. I can teach technologies, but how do you teach being structured? How do you make a kid tidy his room? And do I want to teach a 30 year old developer how to write tidy code? Probably not.

After a slightly extended hour or so, I will probably start winding down. I will progressively give you a looser and looser rein in case there is something you want to tell me – stuff you know, and which I haven’t been able to drag out of you.

Don’t lie by omission

A while ago, I was in an interview with a bloke that waited until this last moment to tell me he had already signed a contract with a different company. He couldn’t get out of this contract. I cannot for the life of me understand why he didn’t call me before the interview to tell me this. His CV was good, and he would probably have gotten an interview when his contract ran out after a couple of months. He left me doubting whether I can trust him. Don’t do that. It can’t help your chances. Be honest.

– oh, and if you are looking for a job in the Oslo area as a senior java developer, my company is hiring right now.

Evangelists and developer groups

Friday, February 20th, 2009

I have been silent for a while. There are reasons for that. My two daytime jobs at Objectware take up a lot of time, and so does the family furniture store.

I had thought I would spend the winter writing code. Haven’t. Instead, I have been caught up in reading a number of books. For a change, they are nothing to do with Java. They are to do with teamwork.

I have decided most books about agile methodologies describe a fairytale world, where everyone agrees which methodology should be used. This is almost never the case. In the real world, people disagree.

An example: A while back, I got into a situation where someone wanted to build a wiki page, and we started discussing how the information should be organized. I have been doing document management systems for many years, so my first thought was to have a look at what librarians have been up to. There is a fairly substantial amount of work underlying the Dewey classification system. Recently (the last ten years, that is), people have come up with stuff like topic maps and ontologies. I have been discussing how Amazon and similar sites have taken ontology creation to a new level with a librarian in the family. Instead of some greybeard sitting in an attic somewhere designing an ontology, classifications are made on the spot by the users. If I read “The pragmatic programmer”, Amazon will offer me other books which have been looked at by other people who have looked at “The pragmatic programmer” on their site. This is my world model.

During the discussion about the organization of this wiki, one of the participants stopped the discussion short. “We will use ITIL”, he said. No discussion. Simple. We will use ITIL.

I find what happened in this discussion fascinating. I think this kind of argument is seen a lot in development teams. I am sure I have been guilty of doing it myself. I think this is part of any technology adoption cycle, especially the earlier parts where the evangelists appear.

Evangelist is such a good word for the position that is often taken by someone who wants to adopt a technology. Thou shalt not doubt. Sometimes, this is for the good – the spring framework has killed off EJBs, at least around here. Good riddance.

Other times, we get testing for the sake of writing tests, we get “SOA is the same as web services”, “agile means not writing documentation and standing up” and all sorts of other easy solutions which look good on paper. Buzzwords.

Next time this happens, try to ask “why”. I have great fun doing this – at least as long as I won’t get hurt by the project going bad. If you get a sensible answer that does not lead to a circular reference, walk away. You are probably more needed somewhere else. You clearly have a well-reasoned person on your hands, maybe lacking a bit in communication skills, but someone who has thought things through. Keep that guy happy. He is at least worth his weight in silver.

If you are strung up as a disbeliever, ridiculed, told about “best practices”, or get pitted against God (meaning a reference is given to someone outside the room), there may still be hope. Whoever is talking to you may want to try something out, or have good reasons he is not able to communicate. I have done this myself, sadly. If you are very good, you will be able to get this wish into the open so you can start mitigating risks. There is absolutely nothing wrong with trying something new. It is the only way to get better. The trick is finding the right time.

Then again, there are the pure, honest evangelists. Haven’t figured out what to do with them yet.

This is why I am reading books such as “communities of practice” right now. Someone has to have done this before. Hopefully, there is no need for me to reinvent the wheel. So – no development right now. Gotta get through a couple more books first.