Przejdź do głównej zawartości

Estimation, estimation... ehh

Steve McConnell gives an excellent overview of estimation methods in his great book "Software Estimation - Demystifying the Black Art". Probably, the most prominent part of the book is the Cone of Uncertainty.

On the other hand, we may spot from time to time the sentence "Estimation is waste". So, where's the Truth? Is it waste or not? And is estimation a fine skill to have? Here is my personal opinion:

Estimation is a Good Thing when we want to answer questions like:
  • how many months will pass until the project will have been finished? (if the unit is weeks, don't bother estimating)
  • can we do the work that is ahead of us with the staff the we have, or do we need more people / more teams in order to do it? How many do we need?
  • in order to satisfy customer needs, we can implement solution A, B or C; the solutions have different costs and different attributes in terms of scope, risk, maintenance, etc. Estimation of cost helps us with making the right choice
Estimation is unnecessary and is really pure waste when:
  • we have some work ahead of us that we need to undertake now, regardless of cost
  • we have ahead of us a chunk of a bigger effort, such as a small feature or a group of user stories and we feel this work will take us just several iterations, or less, to accomplish

The last bullet may be surprising at first, but let's honest about it: a team of N people is working on something. The team is asked for an effort estimate for several next user stories. Usually, the person asking the question imagines that the effort associated with this work is X. The development team is telling them this is twice as much or half of X. What serious decision can be made in this situation based on comparing X with 2*X? Providing any number in this case opens possibility for endless discussion. The best thing the team can do is to work on these user stories and do not waste their time arguing what the "real" effort estimate should be. Velocity is much important and tangible measure here, than effort.


Popularne posty z tego bloga

Unit Testing code with IO file operations (in Python)

We may often come across a piece of code that was written without Unit Tests at all. In addition, the piece of code may be dealing with IO like file writing and reading, which makes it more difficult to Unit Test it when we are trying to refactor and modify. Let's suppose the code in question looks like this:

def writeInitialsToFile(filename, name, surname):
    initials = name[0] + '.' + surname[0] + '.'
    with open(filename, 'w') as file:

def readInitials(filename):
    initials = None
    with open(filename, 'r') as file:
        initials = file.readline()
    return initials

A straightforward and bad idea would be to write a couple of Unit Tests that make use of a real file and simply test the reading and writing. Is therea a better way to test this code?

First of all, we need a way to replace the real file with something else. For both reading and writing we will now have a couple of functions, one that expects a stream fo…

Piotr's Less Obvious Advice on Google Mock: State maintenance

Google Mock provides several ways to maintain state inside mock objects. One way of implementing state maintenance is with SaveArg. Consider the following example.

We have a class Configurator, which allows a caller to set and get values of a parameter:

class Configurator

    virtual ~Configurator() {}

    virtual void setParamX(int n) = 0;
    virtual int getParamX() = 0;

And we have a class Client that calls Configurator's methods and it also has a method incParamXBy, that can be used to increase the current value of paramX by a certain value.

class Client

    Client(Configurator & cfg);
    virtual ~Client() {}

    void setParamX(int n);
    void incParamXBy(int n);
    int getParamX();


    Configurator & _cfg;

incParamXBy internally calls setParamX and getParamX on Configurator:

void Client::incParamXBy(int n)
    _cfg.setParamX(_cfg.getParamX() + n);

Let's assume that the initial value of paramX is A and that we want to increase paramX by…

Piotr's Less Obvious Advice on Google Mock: Returning new objects from a mock

Google Mock provides a way to return newly created objects from a mock method. Suppose we have a  Generator class that is supposed to generate new objects when createNewRecord method is called:

class Generator
    virtual ~Generator() {}
    virtual Record * createNewRecord() = 0;

...and suppose we want to mock this class:

class MockGenerator : public Generator
    MOCK_METHOD0(createNewRecord, Record * ());

Suppose the caller class Client has run method defined as follows:

void Client::run()
    for(int i = 0; i < 3; i++)
        rec_tab[i] = gen.createNewRecord();

We want the mock to return a pointer to a new object each time createNewRecord is called. This is how we can express this in the test code:

TEST(ClientTest, CanRun)
    MockGenerator gen;
    Client c(gen);

    EXPECT_CALL(gen, createNewRecord())
                 //this is equivalent of returning new Record(1,2,3)