Thursday, April 09, 2009

Pride as a virtue

NY Times has an article about the role of pride.

When All You Have Left Is Your Pride

"I have a new client, a laid-off lawyer, who’s commuting in every day — to his Starbucks,” said Robert C. Chope, a professor of counseling at San Francisco State University and president of the employment division of the American Counseling Association. “He gets dressed up, meets with colleagues, networks; he calls it his Western White House. I have encouraged him to keep his routine.”

The fine art of keeping up appearances may seem shallow and deceitful, the very embodiment of denial. But many psychologists beg to differ.

To the extent that it sustains good habits and reflects personal pride, they say, this kind of play-acting can be an extremely effective social strategy, especially in uncertain times.


The article goes on to explain how pride in yourself can lead to other people getting a better impression of you ("dominant but also likable").

I find the article quite interesting for several reasons.

The first reason is because it relates to myself. When I was younger, I was quite shy, and while I can still be somewhat shy in certain social settings, I doubt that anyone who works with me would consider me shy. The reason for this, is that I have a great deal of pride in my work and my abilities regarding it, and thus don't see any reason to hold back. This has helped me behave less shyly in other settings as well.

A second reason is that explains something about the dynamics around consultants. Successful consultants are not only good at their work, but they are also somewhat arrogant (prideful, if you prefer). This doesn't always go over well, but in most cases I've found that consultants get along pretty well, not only with each other (regardless of their company background), but also with their clients. The study regarding other peoples' perception could explains some of this.
Of course, consultants who show themselves to be less competent than expected, will often find themselves quite disliked. So pride is not enough, in the long run - there must also be some ability to back it up.

Labels: , ,

Monday, April 06, 2009

Debugging friendly code

When you often take over other people’s code, you often start getting your own pet issue which you focus on. Well, my pet issue is debugging, or rather ease of debugging. I don’t want to have to know and understand the whole business domain, program or component when I want to fix an error (bug). Most of the time, it should be possible to fix errors by stepping through the code while debugging, and finding the error.

For this to be possible, however, requires the code to be debugging friendly. By this I mean that each class, method and even code line should have well defined responsibilities, which leaves no doubt where and how the error occurred.
This sounds all well and fine on the abstract plan, but how does it relate to real code? Well, that’s of course a little harder to say, but I can give some general guidelines which should be followed to achieve this.


  • Methods should be limited in scope. E.g. if you need to implement a method which fetches something from the database, the method should not also be responsible for putting the data in the cache or convert the data into a different data type. If those things are necessary, a method should be made for each of those functionalities.

  • Methods should be generalized as much as possible. Instead of copy and pasting methods and then modifying them to suit your needs, see if it isn’t possible to generalize the functionality in some way or other, so just one function is responsible for it.

  • Methods, parameters, classes, variables etc. should have telling names. Don’t pass x, y, z along as parameters in a method call. On the other hand, don’t make long names explaining the exact circumstances when it’s obvious from the scope what it is. The id of a customer object doesn’t need to get called customer Id.

  • Use local variables! Martin Fowler might disagree, but he probably doesn’t have to debug other peoples’ code very often. When you call methodX(methodY(Z)) it’s not possible to easily see whether it’s method or methodY which causes the null pointer exception.

  • Make unit tests for, at least, the critical methods.

  • Comment the code. Don’t explain the obvious, but rather focus on explaining the assumptions behind what you’re doing.

  • Check parameters for illegal values. If your parameter should never be null, then check for that – in case it is null, then throw an exception, explaining the problem. This shows other people (or a later you) that someone thought of the possibility, and didn’t just forget to handle null values as input parameters.

  • Ensure that your method behaves in a uniform way, i.e. giving the same parameters the method should always behave the same way (barring other dependencies). I once experienced a ToString() method in a class which always appended something at the end of the string, causing the behavior to different dependent on whether the method had been called before or not.



All of these things might seem simple, but when the project is 3 months over time, your customer or project leader (or both!) is breathing down your neck, then it’s easy to cut corners. You might also know the system and/or domain very well, which allows you to make some assumptions which are not obvious for others – not only does this make it harder for others to debug, but it also might cause people to use the code in the wrong way.

So, what happens if you come across code, or inherit code, which doesn’t conform to my guidelines? Well, be bold and refactor. Do it one step at the time – if method calls are used as parameters, make local variables. If methods are responsible for several things, split it into several methods with distinct responsibilities, and so on. And of course, make sure that there are unit tests.

Labels: , ,

Saturday, January 17, 2009

Error-driven software development

When developing software systems, there are a number of systems development types out there, e.g. test-driven development (focuses on making tests before implementing), and what might be called requirements-driven development (focus on finding all the requirements before implementing). Unfortunately, there is a type of development that I all too frequently come across, which I've come to call error-driven development.

Error-driven development is systems development, where everything is done in reaction to errors. In other words, the development is reactive, rather than proactive, and everybody is working hard, just to keep the project afloat, without any real progress being made.

I should probably clarify, that I am not speaking about the bug fixing phases, which occurs in every project, but rather the cases where the project seems to be nothing but bug-fixing (or change-requests, which is to my eyes is a different sort of bug reports), without any real progress being made.

Unsurprisingly, this is not very satisfactory for any of the people involved. What's more, it's often caused by deep, underlying problems, where the errors are just symptoms. Until these underlying problems are found, the project will never get on the right track, and will end up becoming a death march.

The type of underlying problems, which can cause error-driven development, could be things like:

  • Different understanding of the requirements for the software among the people involved. Some times the people who make the requirements have an entirely different understanding of what the end system should be like than the end users.

  • Internal politics. Some departments or employees might have different agendas, which might lead to less than optimal working conditions.

  • Lack of domain knowledge among the people involved. If you're building e.g. a financial system, it helps if at least some of the people involved in the development have a basic idea of the domain you're working within.

  • Bad design. Some times early design decisions will haunt you for the rest of the project.

  • Unrealistic time constraints. If people don't have time to finish their things properly, they will need to spend more time on error fixing later.



There are of course many other candidates, and several of them can be in play at the same time, causing problems.

No matter what the underlying problems are, the fact is, that just focusing on fixing bugs and implementing change requests, won't help. Instead it's important to take a long hard look at the project, and see if the underlying problems can be found and addressed.

This seems trivial, but when you're in the middle of an error-driven development project, it's hard to step out and take an objective look at it. What's more, you might not be able to look objectively at the process. Often, it requires someone who hasn't been involved from the start, to come and look at things with fresh eyes.

As a consultant who often works on a time-material basis, I often get hired to work on error-driven development projects. The reason for this is simple: often it appears to the people involved, that the project just need a little more resources, so they can get over the hurdle of errors, and then it will be on the right track. When hired for such projects, I always try to see if there are some underlying problems which needs to be addressed, instead of just going ahead and fixing errors/implementing changes. Unsurprisingly there often are such problems.

Frequently these problems can be fixed fairly simply (reversing some old design decisions, expanding peoples' domain knowledge, get people to communicate better, implement a test strategy, use agile methods etc.), while at other times, they can't be fixed, only taken into consideration, allowing you to avoid the worst pitfalls.

So, my suggestion is, if you find yourself in a project which over time has turned into an error-driven development type project, try to take a long hard look at what has caused this, instead of just going ahead and try to fix all the errors/implement the changes. Error reports and change requests are just noisy symptoms in most cases, and will continue to appear as long as the real problems aren't addressed in one way or another.

Labels: , ,

Saturday, December 06, 2008

The strange case of IT Factory

The Danish IT sector, and indeed the entire Danish business world, has been shaken in the recent week, by the story of how one of the most successful growth stories in recent years have turned out to be pure fiction, based on massive fraud.

For my Danish readers, there won't be any news in this post, as the Danish press has been covering the story extensively. I haven't, however, found any international coverage, except some coverage of the fact that the Bjarne Riis' cycling team has lost one of its major sponsors.

The company in question, IT Factory, and was a mixture of a software house, a consulting company, and some sort of license dealership for, among others, IBM.

In 2003 the company went bankrupt, and some investment partners bought it up, and inserted a new daily leader, Stein Bagger. Under his leadership, the company turned around pretty fast, and started to show impressive growth, becoming one of the market leaders, according to its yearly financial reports.

In the last couple of years, the company has won a number of awards by among other Børsen (a daily business newspaper), Computerworld, and Ernest & Young, because of its impressive numbers.

A lot of us in the business were somewhat puzzled by this, since no one appeared to neither actually know quite exactly what the company was doing, nor know anyone who had worked there, or worked together with anyone from there. That might not sound so weird, but the IT consulting business is not that big in Copenhagen, so odds are that you've worked together with someone from any of the major players in the market.

Of course, such things matter little, compared to the results, and we were all impressed by the financial reports from them.

Then, last week, the truth began to appear.

The head of the board of directors of the company, Asger Jensby, went public with the news that Stein Bagger had disappeared a couple of days before, while at a business conference in Dubai with his family (leaving his wife and his daughter behind).

The same day Bagger disappeared, Asger Jensby had found out that Bagger had told someone else, a business partner Alan Vestergaard, that they (Bagger and Vestergaard) would take over the company from Asger Jensby. Vestergaard was under the impression that everyone was in agreement about this, but Jensby had never heard about this before.

This, combined with Bagger's disappearance, led Jensby to start an investigation. The first couple of days, the investigation lead nowhere - everything appeared in order - but then they found a secret office that Bagger had leased close by, in which they found some incriminating documents.

This lead to Jensby going public with the news of Bagger's disappearance, and the news that it appeared that there had fraud in the region of $100 million. At the same time, the company filed for bankruptcy.

Following these news, there have been more investigations into the matter, and the fraud appears to be closer to $200 million.

Naturally, the question arise: How could this go on, without anyone knowing?

It seems that Bagger used a number of fake companies all over the world, selling and buying stuff to and from IT Factory, thus inflating its income, while enabling him to get money out of the company.

More precisely, what appears to have happened, is that Bagger would make a fake company that would sell some computers to IT Factory. Bagger would then go to a leasing company, making a deal with them, getting them to pay for the computers in exchange for a leasing deal on those very computers.
Of course, no actual computers existed, but only Bagger knew that.

Then, when time came to pay the leasing rate, Bagger would use another fake company to buy a bunch of licenses - enough to pay the bill for the leasing.

Any given rate of the leasing is of course much smaller than the entire sum, so even if it was 10% of the cost, there would still be 90% of the money left. And there would still be no computers.

Stein Bagger appears to be a very charismatic person, who were able to convince people that whatever doubt they might have, were unfounded. This explains why none of the members of the board of directors started to ask questions, or rather, why he was able to convince them that they didn't need to see some information on the customers, when they asked about them.

Another factor was of course greed. The company appeared to be going really well, and the customers always paid on time.

Still, some people were asking questions. A freelance journalist, and blogger, Dorte Toft (link in Danish) had raised some very serious questions when the Danish Computerworld gave IT Factory the prize for IT company of the year a few months back.

Her digging showed that there were serious questions that one could raise about IT Factory, and even more so about their customers. As a matter of fact, the two customer cases that Computerworld got for their article about IT Factory when they received the prize, were run by two Swedish men who had been found guilty of fraud in the past.

The Danish tax department were also investigating the company for fraud with sales taxes. Something any member of the board of directors should have seen as a serious warning sign.

In other words, the warning signs were there, one just had to look for them. Maybe it would not lead one to realize how badly the situation was, but it would lead one to understand that there was something very wrong.

My prediction is that there will be some legal procedures happening against the board of directors, and I'll also predict that at least Jensby will found guilty according to the rules of the liability for the board of directors. I also think that the accounting company responsible for signing off the company's financial records, KPMG, will get fined.

Update: It appears that Stein Bagger has turned himself in at a police station in Los Angeles. I'll write more about this case, as the story develops.

Labels: , , , , ,