Class design

Dec 31, 2008 at 2:41 AM
A couple of comments:

1. In TransactionBase you modify ToString() to be abstract and therefore forcing any derived class to override it. This seems unecessary since it's not explicitly used by anything. Let the derive class decide if it would like to override ToString(). If you needed a specific behavior, rather declare an interface that will make such a meaning clearer and have your abstract base class derive from it.

2. There is quite a bit of code duplication in AssetTransaction, BankTransaction, CashTransaction etc. Rather create a base class that contains all the common members: ClearedStatus, Number, Payee, Memo, Category, Address etc.

3. Once you have done (2) it actually becomes clear that some of these classes have no difference except their type and ToString(), which probably indicates that you don't need specific classes for them in the first place. You can still have separate collections in your QifDom that keep logical things together (like Cash or Bank transactions) but the actual data can be of the same Type.

4. There are three public classes, QifDom, ExportEngine and ImportEngine. QifDom is basically a data structure that is used by the Import and ExportEngines respectively. It doesn't have any behavior itself. The "Engine" classes are also static. I think a more elegant design might have been to have one public non-static class, the QifDom that has a Load and Save method respectively (or Import and Export if you like). This makes using the "api' simpler to use and more obvious. Also by being non-static you allow people to extend the behavior in future (static classes cannot be inherited from).

I hope this discussion will be seen as positive comments and nothing else. I'm quite happy to contribute some of these suggestions in the hope to improve this project.
Jan 3, 2009 at 5:03 AM
Thank you for the feedback. I'll need some time to go over each of these and implement, but I'm a little busy but I should get it done soon. As for the poor design, I did the core design a few years ago and only recently resurrected it. Looking back, I have to ask myself, "did I write that?" Again, thanks for the great feedback!
Jan 6, 2009 at 6:50 AM
I've incorporated your feedback and checked it in, but have not provided a binary version for download. I also added missing XML comments. In addition to making instance members available for importing and exporting, I moved the static versions into QifDom and removed the two separate classes for importing and exporting. This will allow for either type or instance invocation, to best suit all needs. If this works for you, I'll go ahead and update the download files and the project page to describe the new API.