| There's another code smell that every programming whiz kid produces at some point: over-engineered. All code has a cost, primitives have a lower base cost because they are universal in the language and thus every programmer will automatically know how to use them. Before introducing a custom object with yet another API to be learned, you need justification. > Implement Money class if you need to deal with money, it’s much better than using floats all over the place. Don’t use Hash for configuration objects, use a custom Configuration class instead. Let's pretend he said integer since floats for money is outright broken. Yes, Money is a clearcut case where having a money-specific API is both intuitive and immediately useful. Configuration on the other hand is debatable. If you're just doing things a hash does then it's fine. If you find yourself with lots of helper methods or repeating the same transformations over and over then that's when you have a code smell that may warrant lifting configuration to its own level. But the critical thing is to remember that there's a non-trivial cost to creating domain-specific objects. |
Oh, and might I suggest that you consider doing it in pennies rather than fractional dollars? It will work out better.
Better to understand the underlying territory, I think. That would not be over-engineering.