File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
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: 38
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://aspose.com/file-tools
 
subject: Problem in calculating financial objects with cyclic dependencies
 
Similar Threads
Longer Post - ALL IBM ICE EXAM Q's for UML
Answers to IBM 486 sample test
[LONG POST-1] Pre-assessment test
PreAssessment Questions and Answers
another 486 question -ugh!