Newbie questions relating to all sorts of things :-)

Newbie questions relating to all sorts of things :-)

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


tkd posted on Thursday, October 09, 2008

1. When a BO is remoted to a client, some changes are made. When the object is Saved, is the entire object sent back to the server or only the dirtyobjects? From what I can see its the whole object which makes it a bit inefficient if the object has a child relationship with lots of records in it.

2. When I am using remoting and I have a number of objects that I want to save, e.g.

Product1.Save

Product2.Save

Each Save is going to be a call back to the server. Can those saves be wrapped in one transaction? I see Transactional support but can that work over the remote wire?

 

3. Possible to collect the Product.Save from the previous example and bundle them as one call back to the server? If you had 100 purchase orders being created together by an end of day process, it would be nice to be able to do a collection save on all of them to reduce the network calls. But I don't think this one could work, given that the code to handlign the remoting would be in the data portal in the CSLA object itself?

4. Is there any functionality to generate an XSD from your business object and then be able to receive an XML from a third party, validate against the XSD and then load that XML into a CSLA object? To me would provide an SOA type interface to external clients.

5. With the WPF components there is a CSLA notification event that can be used to determine whether a field is readonly, enabled, etc. Can this be used to actually hide the component? For example, users of certain levels should not even know some fields exist.

6. Can these notifications be used on any WPF component or only a subset prescribed by CSLA?

7. I saw some sample CSLA code like this.

                       ' We create the order
            Dim objOrder As Order = Order.NewOrder
            objOrder.CustomerID = "CHOPS"
            objOrder.EmployeeID = 1
            objOrder.ShipVia = 1

            ' We create the Order Detail
            Dim objDetail As OrderDetail = OrderDetail.NewOrderDetail
            objDetail.Product = objProduct
            objDetail.Quantity = 100

            ' Add the OrderDetail to the order
            objOrder.Orderdetails.Add(objDetail)

            ' Save the Order
            objOrder.Save()

The objDetail isn't added until the end. I can think of a case where I would want the object added first and then set the product ID. For example, I need to ensure the item on the detail line is for the supplier on the order. If I did add the objDetail to OrderDetails first, does the child know its parent? So in the validation code could I do something like?:

  if item.supplier <>  parent.supplier 
     error 

8. Can a child object belong to more than one type of parent, e.g.

Order -> OrderLines -> ItemDetail

Invoice -> InvoiceLines -> ItemDetail

9. Can you build light weight CSLA objects. For example, I need to get data from the server but its for info only so I don't need to worry about implementing delete or update methods. Does the object still carry the overhead of those methods?

10. I know via a config flag you can say whether to be two tier or three tier application. Can you configure certain business objects to go to one server and others to go to a different one to help in load balancing?

 

 

That will do for now. None of these are deal breakers for me. Well 1 might be. Using a dataset/datatable method I would expect to only get the deltas come back. Its a lot more efficient when doing just a few updates on a lot of records.

I'm mainly just interested to know what support there is for them. I've been doing a lot of reading around on the NET there are some people who really like CSLA and then there are a number who seem vehmently opposed, espieclaly the DDD guys. Thing is for all their 'this can be done better with DDD, n-hibernate,e tc', I still haven't seen examples of frameworks that handle the connect of the object to the user interface through databinding as well as this, that does proper tracking of the updates especially deletes on child lists, that handles n-tier well as transparently as this. Its somewhat similar to the dataset type approach we currently have and if I was wanting to write a framework from scratch is probably the way I would go about it. I guess its all trade-offs, but I think I'd be getting a lot of power with CSLA to quickly build LOB applications.

 

richardb replied on Thursday, October 09, 2008

Lots of questions :-)

tkd:

1. When a BO is remoted to a client, some changes are made. When the object is Saved, is the entire object sent back to the server or only the dirtyobjects? From what I can see its the whole object which makes it a bit inefficient if the object has a child relationship with lots of records in it.

In a remoting situation the entire objects data would be serialized across the wire, but once on the server only the dirty objects would then cause a database trip. 

2. When I am using remoting and I have a number of objects that I want to save, e.g.

Product1.Save

Product2.Save

Each Save is going to be a call back to the server. Can those saves be wrapped in one transaction? I see Transactional support but can that work over the remote wire?

Yes this is possible.  You might have a controlling object that wraps the updates in a transaction.  I think JoeFallon uses this technique nicely.

3. Possible to collect the Product.Save from the previous example and bundle them as one call back to the server? If you had 100 purchase orders being created together by an end of day process, it would be nice to be able to do a collection save on all of them to reduce the network calls. But I don't think this one could work, given that the code to handlign the remoting would be in the data portal in the CSLA object itself?

If I understand you, sounds like you want an editable collection BusinessCollectionBase object.

4. Is there any functionality to generate an XSD from your business object and then be able to receive an XML from a third party, validate against the XSD and then load that XML into a CSLA object? To me would provide an SOA type interface to external clients.

Pass. But I would write a facade on top of my business objects that took the XML, validated it and then set the properties on my business objects.  That way, you can change you business object interface without worrying about breaking the Web Service interface.

5. With the WPF components there is a CSLA notification event that can be used to determine whether a field is readonly, enabled, etc. Can this be used to actually hide the component? For example, users of certain levels should not even know some fields exist.

Pass - not tackeld WPF yet!

6. Can these notifications be used on any WPF component or only a subset prescribed by CSLA?

Pass - not tackeld WPF yet!

7. I saw some sample CSLA code like this.

                       ' We create the order
            Dim objOrder As Order = Order.NewOrder
            objOrder.CustomerID = "CHOPS"
            objOrder.EmployeeID = 1
            objOrder.ShipVia = 1

            ' We create the Order Detail
            Dim objDetail As OrderDetail = OrderDetail.NewOrderDetail
            objDetail.Product = objProduct
            objDetail.Quantity = 100

            ' Add the OrderDetail to the order
            objOrder.Orderdetails.Add(objDetail)

            ' Save the Order
            objOrder.Save()

The objDetail isn't added until the end. I can think of a case where I would want the object added first and then set the product ID. For example, I need to ensure the item on the detail line is for the supplier on the order. If I did add the objDetail to OrderDetails first, does the child know its parent? So in the validation code could I do something like?:

  if item.supplier <>  parent.supplier 
     error 

I'd probably do this.

            Dim objOrder As Order = Order.NewOrder
            objOrder.CustomerID = "CHOPS"
            objOrder.EmployeeID = 1
            objOrder.ShipVia = 1

            ' We create the Order Detail
            objOrder.Orderdetails.Add(productid:=1001, qty:=100)

            ' Save the Order
            objOrder.Save()


In the Add method you could put a check in to lookup the product ID to make sure it is for the same supplier.  Of course, in your UI code you would also just show products for the chosen supplier.

8. Can a child object belong to more than one type of parent, e.g.

Order -> OrderLines -> ItemDetail

Invoice -> InvoiceLines -> ItemDetail

Yes subject to your OO design.  You can do TypeOf checks to see what type of business object you have and then act accordingly.

9. Can you build light weight CSLA objects. For example, I need to get data from the server but its for info only so I don't need to worry about implementing delete or update methods. Does the object still carry the overhead of those methods?

Yes the ReadOnlyBase and ReadOnlyCollection objects are lightweight - they jsut get data.

10. I know via a config flag you can say whether to be two tier or three tier application. Can you configure certain business objects to go to one server and others to go to a different one to help in load balancing?

Pass.

HTH, Richard.

tkd replied on Friday, October 10, 2008

Thanks Richard. That certainly helps in some areas. Now I just need to someone else to answer those other questions ;-)

tmg4340 replied on Friday, October 10, 2008

I can answer one of them.

CSLA does not come with support for DataPortal routing by BO "out of the box".  But you can get what you want by developing a custom DataPortal proxy.  As far as your app is concerned, the DataPortal runs locally.  But this local DataPortal would use your custom proxy, which would route to the various remote DataPortals by whatever criteria you need.

Creating a custom proxy isn't hard - it's just implementing an interface and creating some configuration information.  This has been discussed before in the forums, so a search should yield you some more info.

HTH

- Scott

Copyright (c) Marimer LLC