Best Practice - UI/Business Layer interaction

Best Practice - UI/Business Layer interaction

Old forum URL: forums.lhotka.net/forums/t/975.aspx


bjohns33 posted on Tuesday, August 22, 2006

Hi all

This is a bit more general than CSLA, but given the knowledge here thought it would be a good place.

Assuming a business layer with Data Transfer Objects for communicating with the DAL, how should this be implemented at the UI layer.

If we have a data intensive UI (intranet in my case) how should the data best be transferred between the BL and UI.  One option is to reference the DTOs at the UI level and instantiate them there - add the new/edited data to the object and then pass it to the BO for saving/validation (this is just an example) - this has the benefit of ensuring type safety at all levels, but also breaks the separation model.

The other option is to call your method in the BL with parameters - should this be named parameters, a datarow or any other option?

I also tend to use generics for binding to data grids etc. rather than datasets - is this correct?

Any thoughts/experiences gratefully received!

Thanks

Ben

RockfordLhotka replied on Tuesday, August 22, 2006

The problem with DTOs is that they are, by definition, simple objects. Too simple to really support data binding (at least for Windows Forms) in a good way. This is one of the primary benefits of using CSLA to create business objects: your objects fully support data binding, allowing for an abstract and fully supported way to allow your UI to interact with the objects.

If your DAL is DTO-based, that's fine. Just create your CSLA business objects so their DataPortal_XYZ methods use the DTOs to load/persist the business object data through the DAL.

Copyright (c) Marimer LLC