Tag Info

New answers tagged

1

You're overthinking this. If your class is: public class Bill { private BillId billId; Collection<BillEntry> billHistory; } Then your Average Balance method properly belongs in the Bill class. public class Bill { private BillId billId; Collection<BillEntry> billHistory; public decimal GetAverageBalance() { ...


1

If your classes should know how to calculate a risk, a price or other metrics, depends on what these are dependent on. E.g. to calculate a price, if you only need all the properties of FinancialInstrument then it should be implemented by the class itself. If you however need some external dependencies like the tax of a specific country, then the calculation ...


3

This sounds like the Visitor Pattern could be helpful. It does not get rid of the dispatching code, but it is a fairly elegantly and standard way to implement dispatching. In Java-style OOP: // an interface for anything calculatable interface FinancialInstrument { // acceptVisitor makes the pattern obvious, // but you might want to pick a more ...



Top 50 recent answers are included