Skip to content
Tutorials Center
My learning

Topics

Lesson 39 of 50 ยท Management, Risk and Professional Practice

Cost Estimation Models

Learn software cost estimation models: lines of code versus function points, the basic COCOMO equations, and three-point estimates, with runnable calculators.

Before a project starts, someone always asks: how long will it take, and what will it cost? Software is hard to estimate because the work is invented as it goes, requirements shift, and no two projects are identical. Still, decisions about budgets, contracts and staffing cannot wait for certainty, so engineers use estimation models: structured ways to turn what you know (the size of the system) into an estimate of effort, duration and cost.

Most models share a two-step shape: first estimate the size of the software, then convert size to effort (usually in person-months, the work of one person for one month) using data from past projects. This lesson covers two ways to measure size, the classic basic COCOMO equations, and the three-point technique for estimating individual tasks. The real models come from published research and industry data, and the calculators here are JavaScript implementations of the published formulas with invented project inputs. They show how the arithmetic works; they are not substitutes for calibrating a model against your own team's history. Agile planning with story points is covered in estimation and planning.

First, a few honest warnings

  • An estimate is a prediction with uncertainty, not a promise. Early estimates are often wrong by a large factor in either direction. The cone of uncertainty describes this: the range narrows as the project learns more.
  • An estimate is different from a target (what the business wants) and a commitment (what the team promises). Confusing these three is a classic source of unrealistic schedules.
  • A model is only as good as its inputs. If the size estimate is wrong, the output will be wrong too, with an impressive number of decimals.
  • Use more than one method and compare. When they disagree strongly, that disagreement is useful information.

Measuring size: lines of code

The simplest size measure is source lines of code (SLOC or LOC), usually counted in thousands (KLOC). It is easy to count automatically once the code exists, and many models were built on it. Its weaknesses:

  • You do not have it when you need it. At the start of a project you must guess the final line count, which is hard.
  • It depends on the language. A task needing 200 lines in one language may need 40 in another.
  • It rewards verbosity. More lines does not mean more value, and good refactoring reduces lines.
  • Counting rules vary: comments, blank lines, generated code, tests.

LOC is still useful for comparing similar projects in one organization and for measuring the size of finished systems.

Measuring size: function points

Function points (FP) measure the size of software by the functionality it delivers to users, not by the code. You count, from the requirements, the following kinds of items:

Item What it is Example
External input (EI) Data coming in that changes something "Add customer" form
External output (EO) Processed data going out An invoice report
External inquiry (EQ) A lookup with no change Search customer by name
Internal logical file (ILF) A group of data the system maintains Customer records
External interface file (EIF) Data used from another system A tax-rate service

Each item is rated simple, average or complex and given a weight. This calculator uses the commonly cited average weights (EI 4, EO 5, EQ 4, ILF 10, EIF 7) to compute unadjusted function points. The full method also applies a value adjustment factor based on general system characteristics (performance needs, data volume and so on); that step is skipped here to keep the idea clear. Function points can be counted from requirements, before any code exists, and they do not depend on the programming language, which is their big advantage. Counting takes training, and different counters can disagree, which is the main disadvantage.

Function points can be converted to lines of code with language-specific ratios drawn from industry data. The ratios below are rough, illustrative figures (in reality they vary widely between organizations), and the point is only how conversion works.

JS Count unadjusted function points

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The same 202-point system becomes a very different amount of code depending on the language, which is why measuring functionality is a fairer way to compare projects across technologies.

Basic COCOMO

COCOMO (the Constructive Cost Model) was published by Barry Boehm in 1981 and is built from data on many past projects. The basic model is the simplest version: it estimates effort and schedule from size in KLOC alone, using two power-law equations:

TEXT
Effort   E = a x (KLOC)^b          in person-months
Duration D = c x (E)^d             in months
Staff      = E / D                 average people

The constants depend on the project mode:

Mode Description a b c d
Organic Small, experienced team, familiar problem, loose constraints 2.4 1.05 2.5 0.38
Semi-detached Mixed experience, medium size, some tight constraints 3.0 1.12 2.5 0.35
Embedded Tight hardware, software and operational constraints 3.6 1.20 2.5 0.32

Two things are worth noticing. First, the exponent b is greater than 1, which says that effort grows faster than size: a system twice as large needs more than twice the effort, because coordination and complexity grow too (a diseconomy of scale). Second, duration grows much more slowly than effort (d is well below 1), so very roughly doubling the effort does not double the calendar time. This does not mean you can compress a schedule just by adding people. Basic COCOMO estimates a nominal schedule, and pushing far below it costs a lot of extra effort.

How COCOMO works

Size in KLOC Estimate thousands of lines.
Power law Effort = a x size to the power b.
Duration A second formula turns effort into months.

The mode (organic, semi-detached, embedded) picks the constants.

1 / 2

Here is a calculator for the three modes. Try changing the KLOC value and rerunning.

JS Basic COCOMO calculator

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Look at the "double the size" lines: the effort ratio is a little above 2 every time, which is the exponent 1.05 at work. The cost line at the end shows the last conversion, effort to money, which simply multiplies by a loaded monthly rate (salary plus overhead).

Beyond basic COCOMO

Basic COCOMO is a teaching model and a rough first estimate. The Intermediate COCOMO adds cost drivers (about fifteen factors such as required reliability, product complexity, team experience and tool use) that multiply the effort. COCOMO II updates the approach for modern development: it has models for early design and post-architecture stages, scale factors that replace the fixed mode exponent, and can use function points or object points as size input. Two limitations apply to all of them. They need a size estimate you may not have, and they are calibrated on historical data that may not resemble your project (modern frameworks, cloud services and agile practice change productivity a lot). Organizations that use them seriously calibrate the constants on their own completed projects.

Three-point estimates for tasks

Models like COCOMO work at project level. For individual tasks, a common technique is the three-point estimate (related to PERT). Instead of one number, ask for three:

  • O, the optimistic time if almost everything goes right.
  • M, the most likely time.
  • P, the pessimistic time if things go badly (not the worst conceivable disaster).

The expected time is a weighted average that leans on the most likely value, and the standard deviation measures the uncertainty:

TEXT
expected E = (O + 4M + P) / 6
std dev  SD = (P - O) / 6

Software tasks have a long tail: they can take far longer than planned but cannot finish in negative time. So P is usually further from M than O is, and the expected value lands above M. Summing the expected values over tasks gives a project estimate. For independent tasks the variances add (the standard deviation of the total is the square root of the sum of squared SDs), so the total's relative uncertainty shrinks compared with each single task, a small gain that vanishes if the tasks are all affected by the same cause, such as one unreliable service. A range such as "E plus or minus 2 SD" covers roughly 95% of outcomes if the inputs are honest.

JS Three-point estimate for a feature

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Adding up the "most likely" numbers gives a total that is too optimistic, because the pessimistic tails push the expected value up. That gap is one reason single-number estimates tend to run late. Reporting a range with the assumptions behind it is more honest and more useful to the people who plan around it.

Other techniques

  • Expert judgment. Experienced people estimate from similar past work. Fast and often accurate, but biased by individual optimism.
  • Analogy. Compare with a finished project of similar size and adjust (also called analogous estimation: start from the actual effort of a similar past project, scale by relative size and add the differences).
  • Parametric. Multiply a measured size by a unit rate taken from history, for example 12 person-hours per function point or 30 KLOC at 2.5 person-months per KLOC. COCOMO is a parametric model with calibrated formulas. Sizes in thousands of delivered source instructions are written KDSI (the same idea as KLOC).
  • Wideband Delphi and planning poker. Several estimators give numbers independently, discuss the differences, then re-estimate; this reduces anchoring on the first number spoken (estimation and planning).
  • Bottom-up. Estimate every work package from the work breakdown and add them up, as in project management basics. Accurate but only possible once the work is understood.
  • Reference-class data. Use the distribution of results from many past projects, which is the best defense against optimism.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Why can function points be an advantage over lines of code for early estimates?

    Function points measure delivered functionality and can be counted from requirements, so they work before any code is written.
  2. 2. In basic COCOMO, what does an exponent b greater than 1 mean?

    b > 1 is a diseconomy of scale: coordination and complexity make bigger systems cost more per line.
  3. 3. A task has O = 2, M = 4, P = 12 days. What is its three-point expected value?

    (2 + 4 x 4 + 12) / 6 = 30 / 6 = 5 days.
  4. 4. What is the difference between an estimate and a commitment?

    Estimates, targets and commitments are different things, and mixing them up leads to unrealistic schedules.
  5. 5. Why is a size estimate the biggest weakness of a COCOMO-style model?

    The model converts a size guess into effort. A poor size guess therefore produces a precise-looking but poor estimate.

Summary

  • Estimation models usually estimate size first, then convert size to effort with data from past projects.
  • Lines of code are easy to count after the fact but hard to predict and language dependent; function points measure delivered functionality from requirements.
  • Basic COCOMO is E = a x KLOC^b person-months and D = c x E^d months; the mode sets the constants, and b above 1 means a diseconomy of scale.
  • Three-point estimates use (O + 4M + P) / 6 and (P - O) / 6; report ranges, not single numbers.
  • Estimates are not targets or commitments; use several methods and calibrate on your own history.

Next: Configuration and Change Management.