Re: Get/Set vs Public Variables
- From: "Rene" <a@xxxxx>
- Date: Tue, 5 Feb 2008 17:08:34 -0600
Second, chances are really low that a construct like
class Person
{
string name;
string firstname;
}
EVER will need any functionality in getters and setters for the two string
fields.
Other than for experimenting, I have never bee able to do something like you
mentioned.
For example, if this was your typical business object, the name and last
name properties will probably include checking for certain rules such as
making sure that the last name of the person is not blank or does not exceed
the characters allowed on the database.
Then you are probably going to want to add some sort of security checks
where you may want to throw an exception if the user does not have the
permission to change this value.
The list goes on and on. Adding business logic to your getters and setters
in your bussiness objects make your application more dynamic and robust.
Cheers.
.
- References:
- Get/Set vs Public Variables
- From: JB
- Re: Get/Set vs Public Variables
- From: Jon Skeet [C# MVP]
- Re: Get/Set vs Public Variables
- From: Paul Werkowitz
- Get/Set vs Public Variables
- Prev by Date: Re: Get/Set vs Public Variables
- Next by Date: Re: I'm calling Marshal.ReleaseComObject but com objects are still leaking. How to properly release MODI.Document??
- Previous by thread: Re: Get/Set vs Public Variables
- Next by thread: Re: Get/Set vs Public Variables
- Index(es):
Relevant Pages
|