Design of data classes that are shared between Web Services and Ap

M

madcowJack

Does anyone know of Best Practices for the design of data classes which are
read and written from and to the server ? We have a number of web apps that
have similar needs and we want to build common data classes that represent
the different scenarios.
Specifically for one application we need a 'view' on a
holders policy and in another circumstance we might only be interested in the
'billing' info related to that policy. We want a common object which both the
web service and web apps will build with. That way we only maintain the code
in one place etc..

I suppose my question is really what do other people use to design data
classes and the namespaces associated with them ?
 
T

Tiago Halm

I hope I'm reading your scenario correctly ... so let me give you my
approach.

I normally design a DAL (Data Access Layer) to access the database. I also
design a BAL (Business Access Layer) which basically reflects the expected
business scenario. Afterwards, this same BAL (an object object oriented
model), can be exposed in several ways, where 2 of the most common are:

** WebApps
In this case, and for GridView (as an example) I design a simple object
without behavior to simply be used as an object data source for the
GridView. This simple object is the one that knows how to bridge the BAL to
itself. Basically, its not the BAL that is used directly in the ASP.NET
controls, but an object which may be different according to the visual needs

** WebServices
Again, in this case I design a simple object (DataContract) without behavior
to simply be used as a flat structure for SOAP exposure. This simple
structure, again, is the one that knows how to bridge the BAL to itself. And
again, its not the BAL that is used directly in SOAP (WCF, WSDL), but an
object which may be different according to the SOAP needs.

To conclude, its the BAL that is shared. Each kind of exposure (which may be
designed by other teams) is responsible for using the BAL indirectly to
expose the required data performing any transformations it feels required
(example: via WebApp a BAL numeric value is exposed with currency format,
via WebService is exposed with numeric format and another property with the
currency type).

Hope it helps,
Tiago Halm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top