B
Ben
I have a small argument with a co-worker about proper design, i wanted
to get some more feedback:
we are designing an object model for a client/server system using c-
sharp -- one of the classes is "Client", it holds properties such as
'computerName', 'OSType', 'LastScanDate', etc.
it has a ton of properties (maybe ~40 as of now) all stored in a sql
table row. we also have other similar classes that will have many
properties...
my plan was to write the object so that it has an internal DataRow
variable to hold the information and use a generic GetPropertyValue
and SetPropertyValue to allow the programmer (me, in this case) to
update the object. I also want to include a Save() function, which
will verify the variables are valid and if so, it'll commit the row to
the DB.
This seems more efficient to me and keeps the code cleaner... if we
ever add more fields to the table, it'll be a matter of just verifying
them (if needed) in the Save function. Also if i really want to
verify a value upon setting it, i can put some switch statement inside
the SetPropertyValue that will do the check for a certain field.
He disagrees and wants a setter/getter for each property and says it's
the only proper way for object-oriented programming.
Can anyone offer some opinions on the matter? I've used APIs before
from Microsoft that seem to have some properties exposed, but a lot of
them were accessed via generic functions like Get/Set PropertyValue.
Thanks!!
to get some more feedback:
we are designing an object model for a client/server system using c-
sharp -- one of the classes is "Client", it holds properties such as
'computerName', 'OSType', 'LastScanDate', etc.
it has a ton of properties (maybe ~40 as of now) all stored in a sql
table row. we also have other similar classes that will have many
properties...
my plan was to write the object so that it has an internal DataRow
variable to hold the information and use a generic GetPropertyValue
and SetPropertyValue to allow the programmer (me, in this case) to
update the object. I also want to include a Save() function, which
will verify the variables are valid and if so, it'll commit the row to
the DB.
This seems more efficient to me and keeps the code cleaner... if we
ever add more fields to the table, it'll be a matter of just verifying
them (if needed) in the Save function. Also if i really want to
verify a value upon setting it, i can put some switch statement inside
the SetPropertyValue that will do the check for a certain field.
He disagrees and wants a setter/getter for each property and says it's
the only proper way for object-oriented programming.
Can anyone offer some opinions on the matter? I've used APIs before
from Microsoft that seem to have some properties exposed, but a lot of
them were accessed via generic functions like Get/Set PropertyValue.
Thanks!!