Abstraction

The notion of abstraction is extremely important for writing good programs or designing good systems. Basically, the idea is that you want to avoid getting hung up on the details: you want to separate the things that change from those that
don’t
.

In Excel spreadsheets the easiest example of abstraction is the use of names. You can define a name to refer to a particular range: for example, you could define VATrate to refer to cell D3 on sheet TaxCalcs. By using a name for this, you have abstracted away two levels of detail:

  • The actual VAT rate to use; instead you use the value in cell D3 on sheet TaxCalcs.
  • The actual cell that contains the value; instead you use the name VATrate.

Using abstraction usually has advantages for maintainability, and we can see several of them in this example.

  1. A formula that reads =B26*(1+VATrate) is much easier to understand than either =B26*(1+$D$3) or =B26*1.175
  2. If you want to change the rate of VAT that you are assuming, it is much easier to change the value of a single cell than it is to go through all the formulae in the workbook looking for places where 17.5% is used, and changing them all individually.
  3. If you want to change the layout of your sheet, it is much easier to change the definition of the name VATrate than it is to change all references to cell D3, or to make sure that you drag and drop the cell or cut and paste it in such as way as to preserve all the references.

There are other ways of making use of the advantages of abstraction, but the use of names is the most common in Excel.

Leave a comment

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.