Method Calls: Using Object References

As a general recommendation, I would pass in object references to DAL, BAL, or other methods in your application, rather than passing in individual properties.  The reason is you can conceal the properties you need in your code.  For instance, look at this method:

public OrderCollection GetOrders(int customerKey) { }

Now, suppose you change the property you use to query customers from an integer to a guid.  This requires an interface change to the BAL or DAL object.  As an alternative, if you provide this:

public OrderCollection GetOrders(Customer customer) { }

The field used to get orders isn't directly exposed and can be changed on the fly.

Normally, customer key as an integer will never change; however, it reduces one explicit dependency in your code and all the maintenance associated with interface changes.

Comments

# basic properties

Friday, March 14, 2008 1:04 AM by basic properties

Pingback from  basic properties