Splitting CSLA Business Objects into client-side and server-side methods #2277
Replies: 2 comments 1 reply
-
Part of the solution might be to apply the single responsibility pattern. Each business class (object) should have one responsibility, not more. A responsibility might be "get valid information from the user", so you'd probably create a A responsibility might be "receive a purchase item" that does some database transaction relevant to that responsibility, so you'd probably create a Or perhaps the "receive a purchase item" work requires that the user enter the item ID or something? In which case it might be implemented as a The overall design philosophy is this:
Once your code is running in a data portal operation method, you can access properties, which may trigger rules - all of which will continue to run on the server. Generally speaking, if you have some set of behaviors that must run on the server you'll wrap that set of behaviors into a unit of work object, often derived from |
Beta Was this translation helpful? Give feedback.
-
Thanks very much for taking the time to respond Rocky. Yes we have wrapped up these core shared functions into individual unit of work objects, derived from command base, as you suggested.
To ensure there isn't wastage, AND ensure we never run server-side functions without going via the portal, we have decided that each Unit of work object has
So I think this covers our use case where we have these shared functions (unit of work objects), and shields the developers from having to think about where the shared function might be called from in some future development.
|
Beta Was this translation helpful? Give feedback.
-
From what I understand, the entire point of CSLA business objects is that they are available to both both client-side and server-side operations. Some of our methods can be called from EITHER the client directly, OR as a nested call from some other server-side operations.
eg. the client can call ReceivePurchaseItem, or they can call ReceivePurchaseOrder, which in turn calls ReceivePurchaseItem for each item.
In the first case ReceivePurchaseItem must go across the data-portal first. In the second case we are already on the server.
How do I mark my BOL methods to ensure the developers don't call server-side code directly from the client-side without going over the data portal.
Our current approach is to create an async wrapper for each method that also invokes DataPortal.ExecuteAsync, which then calls the core server-side method. The method name is the original suffixed with 'Async'.
Our internal policy is then:
all UI calls to the BOL must use the Async methods,
all server-side code must NOT use the Async methods.
Does this make sense or are we missing something entirely with our architecture?
Beta Was this translation helpful? Give feedback.
All reactions