jediknight
New member
- Joined
- Jul 23, 2010
- Messages
- 3
- Programming Experience
- 3-5
I had a general question regarding Object creation, Binding and management. Though this question might be better served in the Database Group, I think it is general enough to post right here since it is a more general question.
I've experiemented in the past with creating a Singleton Business Object to bind the properties to the controls on the form. The initial query from the data source is displayed on the form but further queries do are not displayed on the form even though they are displayed in the object. It is easy enough to remove binding entirely and simply assign the values from the properties to the controls and vice versa to maintain only one instance of the business object. I'm not entirely certain how that would effect validation.
When I am not trying to use a Singleton the object creation might look like this:
I'm returning a new Customer Object for every query for the object binding to work properly. What is happening to the objects I am creating? When I call this function multiple times to perform additional queries does the binding object hold those somewhere so if a query is performed again it can reuse the object. What would the advantages of creating a Collection member be to manage these multiple creations?
I've experiemented in the past with creating a Singleton Business Object to bind the properties to the controls on the form. The initial query from the data source is displayed on the form but further queries do are not displayed on the form even though they are displayed in the object. It is easy enough to remove binding entirely and simply assign the values from the properties to the controls and vice versa to maintain only one instance of the business object. I'm not entirely certain how that would effect validation.
When I am not trying to use a Singleton the object creation might look like this:
VB.NET:
Public Class Customer
[INDENT]...(property definitions)[/INDENT]
Public Shared Function Create(ByVal id As Integer) As Customer
[INDENT]Dim cust As New Customer
Dim dt as New DataTable
dt = ExecuteTable(My.Resources.SP_RetrieveCustomerByID, id)
With dt.Rows(0)
[INDENT]cust.CustomerID = .Item("CustomerID")
cust.CustomerName = .Item("CustomerName")
cust.CustomerContact = .Item("CustomerContact")
cust.CustomerAddress = .Item("CustomerAddress")
...[/INDENT]
End With
Return cust
[/INDENT]End Function
I'm returning a new Customer Object for every query for the object binding to work properly. What is happening to the objects I am creating? When I call this function multiple times to perform additional queries does the binding object hold those somewhere so if a query is performed again it can reuse the object. What would the advantages of creating a Collection member be to manage these multiple creations?