This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Can the composite pattern be used to support the following budget structure (a tree): My GUI will allow the input of amounts. Each amount can be broken down into sub-amounts. Basically, the value stored in a node will be the sum of the amounts of its immediate children. I see a difficulty arising because the tree has two types of leafs: horizontal amounts and vertical amounts. The sum of the horizontal amounts and the sum of the vertical amounts will both be equal to the amount of their common parent. Reports will have to be produced grouping the horizontal and the vertical amounts. What is the proper approach to be able to distinguish these two types of leafs? Create two subclasses of Node? Rich
What is the difference between the two types of amounts? Is it only in the grouping?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: May 30, 2002
The two type of amounts are used to explain how the same total may be broken down two different ways. All other totals have only one possible break down and therefore a single child type. A distinction must be made between the leafs only for reporting purposes, otherwise the attributes are the same.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com