Hi guys, this is a typo I'm afraid - sorry.
Although you do touch on a topic that I will be covering in my new book. That of primitive obsession. Take this code...
Code:
decimal apply_vat(decimal price, decimal vat_rare)
{
//logic ....
}
It would be easy to get the parameters confused when calling...
Code:
decimal price_after_vat = apply_vat(1.23, 199.99); // Whoops!
Better to use value types and make things explicit...
Code:
Money apply_vat(Money price, VatRate vat)
{
.....
}
Or better still...
Code:
Public Class Money
{
Money apply(VatRate vat)
{
// return new Money with vat applied
}
}
This way you avoid confusion, you make the concepts of money and vat more explicit and you enable them to encapsulate behaviour.
Thoughts?
Cheers
Scott