Fog Creek Software
Discussion Board

Data hiding

Alright, so here's a question I've been pondering for a while now. I have a survey application that has been nicely divided between business layer and display layer logic. The suryey is entirely described through an XML document held by the business layer.

Is it a good design for the business layer to pass XML nodes to the display layer, which hold information needed for the rendering of questions(scales, text, type, etc)? I've considered creating an object model representing the XML document, but this seems to me to only create work for myself: these objects wouldn't have much action to them(being pretty much only datastores). Also if the XML store changes, that likely means that there is new, added functionality that will need to be reflected in changes to the display layer.


John Christensen
Friday, February 22, 2002

Sounds like the XML mechanism is already doing most of what that object layer would need.  XML is not a bad mechanism for object marshalling.  Do you have objects at either end that do the validation (other than the Parsers?)
That may help more, and they are probabably more reusable.

Keep it simple. 

Friday, February 22, 2002

KISS in fact.

Saturday, February 23, 2002

I strongly dislike everything manipulating raw XML nodes.  Main costs:

* not good for optimization -- sometimes trees are the slow data structure, and you want a layer that caches the info in another structure
* XML is so new that you don't necessarily want to use parsers that use different (non-W3C) APIs

But to avoid this, your display layer could still take on these XML nodes, and hide them from the rest of the display layer by encapsulating them within a class that holds all the operations you would possibly want to perform on them.  If there are any new operations you want, they can be added to the class.

So, you can do the information-hiding anywhere is most natural for you, as long as it's done well.

Saturday, February 23, 2002

Correction.  I meant to say that you don't necessarily want to use W3C apis.  (There are many fast parsers that achieve some of that performance by phrasing things differently... or so their creators believe.)

Sammy (who sometimes types toofast)
Saturday, February 23, 2002

*  Recent Topics

*  Fog Creek Home