.NET 3-tier architecture best practice question...

Associate
Joined
6 Jun 2004
Posts
2,389
Location
London
Ok here's my question:

I have an application I am writing which loads in XML defined report "templates", these report XML files have sections like Inputs, Outputs and QueryBody - the Inputs are displayed to the user, who enters/picks values into each - when run, all the values are merged together to create a query which gets run and then displayed as the template is defined.

I have a 3-tier architecture and I load in the XML files in a data access layer, using a business entity object to return the populated ReportTemplate, which my GUI layer can then use.
The crux of my problem is that the inputs are more like input placeholders which I want to render as controls on a windows form (ie <Input Name="FriendID" DataType="Integer" QueryMapping="f.FriendID"/> - each definition like this is stored in its own ReportInput object, built in the Data Access layer) - in this case because the DataType is "Integer" I want to render a NumericalUpDown control rather than a TextBox. Similarly if the DataType="DateTime" I would want to render a DatePicker control.
I have further complications too, such as mapping an Input to Static Data (already loaded) which displays a ListBox with predefined data in it.

At the moment, to keep the layers separate I have a GUI factory method that takes in the datatype etc and outputs the correct group of controls (setting the DataSource of the ListBox if StaticData is being mapped to etc).
I like this, and it works fairly well, except I find it very inefficient to generate these controls each and everytime I want to view a particular input - ideally I'd want to generate these controls ONCE and store/cache them inside the "ReportInput" business entity object I use already, but this would create a GUI layer-dependency in my business entity objects...Is there any other way to do this? Am I already doing the "best practice"?

Thanks for getting this far!

Happy new year all.
 
Hi,

IMHO one of the things that is to be definitely avoided is tying the server-side code to a specific implementation on the front-end. In fact tightly-coupling any two layers within the application together is generally something to avoid. So, from your design it sounds like you've got things spot on.

I mainly do Java server-side code that outputs HTML web-pages (haven't really touched .Net). In quite a few instances I obtain data in an XML document and then use XSLT stylesheets to produce HTML from the XML. That way the presentation of the data can be changed by using a different XSLT. Not the easiest thing to do (at least I don't find it to be) but very flexible.

However, you want to generate .Net front-ends. One thing I did stumble across was XUL and MyXaml. Click here to view the site for MyXaml. From a quick look it would seem that the MyXaml engine allows you to produce .Net widgets from XML code. So, you could get your data in an XML document and then use XSLT to convert it to the XML document that MyXaml can use. Probably pretty much like what you're doing but possibly worth a look?

Hope that helps.

Jim
 
Back
Top Bottom