I am asked to refactor and maintain an enterprise application. Normally I'm used to using the MVC design pattern. This time however, I'd like to separate everything into layers (multilayered architecture). Something along the lines of (Microsoft Application Architecture Guide, 2nd Edition - October 2009):
My data sources are in general XML files. These files are read and written with the use of JAXB, and this resides in the data-layer. Whenever I load a specific XML a "provider" will use JAXB to construct a tree of objects representing the XML structure. These objects/information needs to be used inside the business, service and presentation layer. Per layer the information needs to be treat differently, i.e. business layer will enforce business rules on the objects/information whereas the presentation layer needs additional UI information to have everything shown to the user.
I'm looking for your tips / experiences when it comes down to using data sources throughout an multilayered application. Should I:
- Create some sort of mapping, such that a new object tree is constructed in every layer?
- Work via the lines of aggregation, such that my data sources can be decorated with extra functionality / information inside an object that lives in another layer?
- Make the JAXB-objects "fat", with an interface which supports all my needs that come from all other layers?
I'd love to hear your thoughts!