Anyone knows some design patterns for hierarchical structures? For example, to manage inventory categories, accounting chart of accounts, divisions of human resources, etc..
Thank you very much in advance
EDIT: Thanks for your interest. I am looking for a better way of dealing with hierarchical items to which they should apply operations depending on the level of hierarchy. I have been studying the patterns by Martin Fowler, for example Accounting, but I wonder if there are other more generic.
The problem is that operations apply to the items must be possible to change even at run time and may depend on other external variables. I thought of a kind of strategy pattern but would like to combine it with the fact that it is a hierarchical scheme.
I would appreciate any reference to hierarchical patterns and you’ll take care of them in depth.
The composite pattern immediately springs to mind. Paraphrasing the wikipedia definition, the pattern allows you to compose objects into tree-like hierarchies (of branches and leaves) and treat single instances, or the composition as a whole, uniformly.
I’ve tended to use it in my work to represent complex view structures but imagine it might be helpful in representing inventory categories or divisions of human resources.