The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Representing money with inflation

I'd appreciate feedback on the following design.

I need to represent money. Part of my application deals with inflation, so it's important that I can store the purchasing power.

My idea is very simple: have a fixed inflation rate for the whole application, and then store each amount in a Money class with a 'amount' and a 'base year' instance variable.

Advantages: Gets rid of 'amount' and 'inflatedamount' pairs throughout the application. Makes math very easy since I can simply inflate/deflate to a common year and then add/subtract as necessary.

Cons: Extra data. Fixing the inflation rate for all money objects.

I'm aware of the floating point issues regarding currency; I have taken care of those.

It seems like too simple of a solution to me and it kind of makes me nervous. Any thoughts?
Anon to protect the guilty
Wednesday, March 01, 2006
Do you deal with international currencies?  Because I think different governments use different base years.

Also - what happens when a government rebases the currency, like Turkey did a few years ago (If I recall correctly, they dropped something like 3 decimal places)
example Send private email
Wednesday, March 01, 2006
I only need to store USD, so that doesn't concern me.

I'm not sure what you mean by 'base year'. Am I using an overloaded term here?

I was thinking that generally I'd enter data in today's dollars, therefore the base year at entry would always be the current one. If I'm dealing with dates in the future I inflate with my fixed rate. For the past, if I wanted I could store the historic CPI and use that each year, though I don't think I'll actually need that.

As far as rebasing it, I don't need that in my application now. Good call though, I hadn't thought of that. I don't anticipate it being a concern with USD, but if I ever did need that refactoring, I think I could handle that internally when I convert by just doing a lookup into a history DB table.

Thanks for raising these issues, I'd not thought of them. I think these things could be added without changing the interface, and since I'm able to do that, I think it'll work.
Anon to protect the guilty
Wednesday, March 01, 2006
"My idea is very simple: have a fixed inflation rate for the whole application, and then store each amount in a Money class with a 'amount' and a 'base year' instance variable."

It is typical to report one number in the press, but I find it hard to believe that every industry bases their decision on that magic number.  The rate of inflation itself also changes from year to year. (It may be 3.2% one year, 3.7% the next.) I believe you were thinking of the historical inflation, which is an average over time.

Looking towards the future, I'd add a table that quotes the inflation for that year, for a specific category (including "all"). The money class can fetch whatever value is appropriate.

So if the money class started in 1999, it can fetch the rate of inflation for "all", for 2000, 2001, 2002 and so on.
Wednesday, March 01, 2006
Yeah, to reinforce what TheDavid said, different sectors of the economy experience different rates of inflation. Home prices in various markets increase at rates exceeding the consumer price index. Technology prices decrease with respect to the CPI.

Etc etc etc.

I don't know whether that level of granularity is important in your application or if you're only concerned with macroeconomic inflation.

But it's something to consider.
BenjiSmith Send private email
Wednesday, March 01, 2006
Your math seems sound. However, if this is for a scientific application, you might want to read up on the different ways to measure devaluation. is a rather good overview. Abstract: it's complicated :-)

Very interesting topic. Can you tell us what you're working on?
Matthias Winkelmann Send private email
Wednesday, March 01, 2006
I'm writing a retirement planning application. I'm not using a complex projection model, just the standard compound interest formula, but doing things like showing the effect of inflation, the advantages of using one type of retirement account versus another, etc.

I realize that I should be consulting a CPA (and probably a lawyer too) on this, but I'm not going to hire one to review my formulas, etc until after I have a product. That way, if I don't follow through (and we all know how hard it is to take a product from concept to delivery), I'm only out my time, and I've learned a lot to use for planning my own retirement (which hopefully will be before I'm 30. Aim high!).

Thanks for the interest! That linked article is very interesting, I suspect that the unskilled wage type statistics are the type I'll be interested in.
Anon to protect the guilty
Wednesday, March 01, 2006
"a retirement planning application"

For this scale, it's usually reasonable to apply the average over the last decade or so and project it forwards (the answer you're after can't be in any way exact over that timespan). I've seen these done as simply as "inflation halves the value of money every N years".

You could also do the sums twice and having top and bottom end computations -- say using 2% inflation and 4% inflation (they're pretty much bounds on recent historical inflation) to give people best and worst case suggestions; what people are usually after with pension planning is making sure that the reasonable worst case isn't all that bad.
Katie Lucas
Thursday, March 02, 2006
>> I'm not sure what you mean by 'base year'. Am I using an overloaded term here? <<

The US government often reports buying power relative to 1970.  Just a year they picked to serve as their base.  I suspect that since it's been 36 years, they'll probably pick a new base year soon. 

For instance: a typical car cost $3,542 in 1970, compared to $21,605 in 2001.

Note that the chart uses constant 2000 dollars, not 1970 dollars.
example Send private email
Thursday, March 02, 2006
Accountants often use a single number to represent the inflation rate, but in reality, your mileage _will_ vary. If you want your models to come anywhere near modeling the world in which we live, I think that you would have to modify your models.
Steve Hirsch Send private email
Thursday, March 02, 2006
For Retirement Planning, I think it's sufficient to track inflation rates depending on region, i.e., the cost of living and inflation is typically lower in the Southwestern desert than in New England. There's not much point in making recommendations based in industries (my earlier advice).

Complicating the matter though, many people on the verge of retirement do consider relocating to a cheaper and/or warmer environment, i.e., Florida, Texas, Arizona or Nevada. So if someone says "I want to move within five years of my retirement date", you'll want to be able to project their finances for the first five years in one region, then the remaining 20 years in another.
Thursday, March 02, 2006
Would it be an oversimplification to just consider inflation as a negative annual return? i.e. if you expect your money to grow by N%/year (in interest/dividends/etc.) and inflation is I%/year (on average) then your actual return would be (N-I)% in today's dollars.

Then you don't have to store inflation values separately, just tack the rate on to annualized gains from various other securities.
Ian Schreiber Send private email
Thursday, March 02, 2006
Ian, your solution works just fine.  It also assumes inflation is a constant, and applies to everyone equally. Going with this train of thought, if I were a retiree, I would like to at least be able to define the rate of inflation. (I punch in 3.2% and see how it affects my finances.  I then punch in 3.6% and see how much worse off those 4 percentage points make me.)

For a "consumer" level product, I would agree that's a reasonable place to draw the line - i.e., no need to get more complex than that.

For more serious financial planning, you're going to want to at least "save" all of these different possibilities and go as far as seeing 3.2% in Florida verses 3.4% in New York, on a year by year basis.
Thursday, March 02, 2006

As casual discussion rather than professional advice:
Depends how much flexibity you want - one possibility is to go for a lookup table for each year into the future, so the 'profile' of future rates can be easily changed. For most individuals looking at pensions they need to understand future money in "todays terms".
Also a good model would allow such questions to be asked as " what if there's accelerated inflation just before I retire?"
Don't know US retirement law , but in the UK typically most of a retirees fund has to be used to by a fixed interest security (called an annuity), which optionally can be indexed linked.
So from that point the UK retiree has a bond, which generates an income stream which itself is subject to inflation.


Thursday, March 16, 2006

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz