# Being Cellfish

Stuff I wished I've found in some blog (and sometimes did)

# November, 2009

 This blog has moved to blog.cellfish.se.
Posts

• #### Pugh Decision Matrix

The Pugh decision matrix is a is a tool to help you make decisions when you're trying to sort out what alternative is the best but they all have their pros and cons. It can also be used to help a group decide on a decision. The way it works is that you first list your alternatives. And you also want to have a default decision (usually doing nothing). List this across the top of a table as in this example.

 Watch TV Go to bed Go to the cinema

Then you need to list the consequences and properties of your decision. List these on the side like this.

 Watch TV Go to bed Go to the cinema Will feel rested tomorrow Saves money Can watch zombie land Can eat popcorn

Each thing on the left then needs a weight, i.e. how important are they compared to each other.

 weight Watch TV Go to bed Go to the cinema Will feel rested tomorrow 2 Saves money 1 Can watch zombie land 2 Can eat popcorn 1

Now it's time to measure the effect of each option. Your default option (if you have any) should be neutral in regards to all effects so put zeros in that column. Then write down if the other options is better or not than the reference (i.e. the default option). If it's better, put a one in that box and if it's worse put minus one there. If effect is comparable to the default option put a zero.

 weight Watch TV Go to bed Go to the cinema Will feel rested tomorrow 2 0 1 -1 Saves money 1 0 0 -1 Can watch zombie land 2 0 0 1 Can eat popcorn 1 0 -1 0

Now calculate the sum for each column and remember to use the weight for each row and you should have a decision on top. In this case go to bed. So how do you feel about that decision? If you think it's good you're done but if not you should revisit the weights and also try to find more attributes to put on the left side. Or maybe even a new option. Repeat until you get a decision you're ready to make.

 weight Watch TV Go to bed Go to the cinema Will feel rested tomorrow 2 0 1 -1 Saves money 1 0 0 -1 Can watch zombie land 2 0 0 1 Can eat popcorn 1 0 -1 0 0 1 -1

So now you have another tool to make decisions. You don't want to use this for all your decisions but it can be useful at times.

• #### How do you reward good service at a restaurant?

I bet your answer to this question is; by giving a good tip. So what do you do if the service was bad? Here I predict two different answers, either you don't give a tip or you complain to the management of the restaurant. If don't tip I bet you leave the restaurant with a bad feeling about your visit. Also the waiter might not know that you were unhappy with the service and think you're just another cheap tourist with no manners. By complaining to management however you typically get a better experience since the restaurant will try to compensate in various ways. This leaves you with a good impression of the restaurant and the waiter knows what he did wrong and can correct the behavior. So in my opinion, talking to management or maybe even the waiter immediately is the best way to handle a bad experience. And by talking to management you also make sure the management knows one of the employees did something wrong. I'm sure they want to know.

But what about really good service? By giving a great tip you make the waiter happy but that's it. And you're not really enforcing specific good behaviors. And maybe even worse; management doesn't know that the waiter did a great job. Why not consider talking to management when you have a really good experience? I'll bet the waiter will be happy even though they'll probably wonder when you ask to speak with the manager. So if you want to be real nice you should probably tell the waiter that you want to talk to the manager and explain what a good job they've done.

And don't stop at restaurant visits. If somebody you work with do something great you should tell their boss too. I'll bet they both want the boss to know when the employee does something good. Don't just strike down on bad behaviors, enforce good behaviors too!

• #### How to prevent the use of "SELECT *"

One good tip for writing good SQL code is to always select the columns you need and never just select everything. Well here is a description on how to actually prevent SELECT * queries (you need to complete a free registration to see the article). The basic idea is to add a dummy column to all your tables and then limit the access to this column using DENY SELECT ON OBJECT for that column. Personally I think this is maybe taking it a little bit too far but desperate times calls for desperate measures, right...
• #### Team Coding Dojo 7

This time we did a new Kata - variant of poker hands. Instead of being so specific about the interface the user story we used for the Kata was simply; Given two five card hands I want to know which hand is the winner. We also choose to use the object calisthenics rules. The biggest benefit from not having a specified interface was that we did not have to do any string parsing and could design our interface as we wanted. That definitely felt like a kick start for an object calisthenics session. In the retrospect we also noted that in some cases it is good to bend the object calisthenics rules for the sake of progress with the Kata. Sometimes it is just not worth following the rules strictly. But each breach of the rules should be carefully considered since the purpose of the rules is to flush out changes you would normally never see.

The poker Kata is definitely an interesting one and I can see how the solution can take many different paths. Looking forward to try it again.

• #### The 2009 Advent calendar situation

Assume that you have some important object that performs some important task. It may look something like this:

```   1:      public class ImportantObject
2:      {
3:          public void ImportantMethod()
4:          {
5:              // Do things.
6:          }
7:      }
```

You've done everything right and created this object using BDD/TDD but one day everything changes. You need to make this object thread safe. The straight forward way to do this would look like this:

```   1:      public class ImportantObject
2:      {
3:          private readonly object _lock = new object();
4:
5:          public void ImportantMethod()
6:          {
7:              lock(_lock)
8:              {
9:                  // Do things.
10:              }
11:          }
12:      }
```

But that is tricky to drive using specifications/tests, right? So over the next 24 days I'll show you a few ways to do this and by Christmas eve we should have something nice that works. And I'll be using xUnit.Net to write the specs/tests.