aspose file tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Problem in calculating financial objects with cyclic dependencies Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Reply Bookmark "Problem in calculating financial objects with cyclic dependencies" Watch "Problem in calculating financial objects with cyclic dependencies" New topic
Author

Problem in calculating financial objects with cyclic dependencies

Maciej Opala
Ranch Hand

Joined: Jul 18, 2011
Posts: 37
Hi,
I've the following problem and need a piece of advice in design.

There are two classes of business objects from financial domain: A and C, and A contains a collection of C. An user may request to calculate (refresh the indexes, recalculate the debt and so on) the objects of this classes. The problem is that A requires some data from the collection of C to be fully calculated and C, also requires some data from A to be fully calculated. Currently, all the calculations are done in on class , fortunately not in one method. This design is in conflict with clean code principle (the code is very messy and unclear) and I'd like to refactor the code. The problem lies in the two-way dependencies.

My idea is to create AbstractCalculator class which will hold the currentlyCalculatedA and other common fields that are required for calculation (configuration, info-services). Then I will create ACalculator and CCalculator that both extend AbstractCalculator, also ACalculator has an instance of CCalculator.
Then in ACalculator:
- A is calculated till possible
- Collection<C> is calculated with usage of CCalculator
- A is calculated till the end
- the state of AbstractCalculator is reseted and waits for the next calculation.

Here is the diagram:




Will it be good designed or maybe someone has a better idea?


 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Problem in calculating financial objects with cyclic dependencies
 
Similar Threads
Answers to IBM 486 sample test
Longer Post - ALL IBM ICE EXAM Q's for UML
[LONG POST-1] Pre-assessment test
another 486 question -ugh!
PreAssessment Questions and Answers