I have two questions about the IBS Store Programming Methodology hopefully someone can clarify.
1) Throughout the CustomersDB class the variable, customerID, is passed into Functions as a String (ByVal CustomerID As String). However, once inside the function(s) the customerID variable is Cast to an Integer, CInt(customerID). Why didn’t they simply declare the customerID variable type as Integer and avoid having to type cast in every function which uses the variable? Clearly, the developers thought of this when they developed IBS, but for some reason they decided to use this technique, presumably for stability. Why?
2) On many of the IBS .aspx pages, ShoppingCart.aspx –for one, there are a number of Sub Procedures which instatiate and dimension the same objects and variables. On ShoppingCart.aspx there are 3 different subs (Sub UpdateShoppingCartDatabase(), Sub PopulateShoppingCartList(), Sub CheckoutBtn_Click) which all instantiate the same object:
Dim cart As IBuySpy.ShoppingCartDB = New IBuySpy.ShoppingCartDB()
Then dimension the same variable:
' Obtain current user's shopping cart ID
Dim cartId As String = cart.GetShoppingCartId()
My question is why didn’t the developers simply declare this object and variable outside any Sub Procedures and make them accessible to all the Subs throughout the page – which would have saved time and called for less code-- ?