Best Practices for Classes

Giganews Newsgroups
Subject: Best Practices for Classes
Posted by:  Steve (Ste…@discussions.microsoft.com)
Date: Mon, 4 Aug 2008

Hello,

I have a (hopefully) pretty simple question.  Let's say I want to have an
"Address" class.  In my class I have an UpdateAddress method, AddAddress
method, DeleteAddress method, etc.

Should my UpdateAddress method have parameters for all of the different
fields in the address (Address ID, Address Line 1, Address Line 2, Address
Line 3, City, State, Zip Code, Country), or should I be assigning these
values to properties in my class and then just calling an Update method
without any parameters.

For instance, after the user hits an "Update" button to update an existing
address, I could do either of the following:

Dim a as New Address
a.AddressID = txtID.text
a.AddressLine1 = txtAddressLine1.text
etc....

a.Update

Or I could do

Dim a as New Address
Call a.Update(txtID.text, txtAddressLine1.text, etc...)

I'm interesting in knowing which way is the preferred way (assuming there is
a preferred method) and why.

Thanks.

Replies