Re: Get/Set vs Public Variables



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.


.



Relevant Pages

  • Re: invoking a method
    ... Getters and Setters are used to encapsulate the ... to a string and add it to another string. ... the same as "inserting" it... ...
    (comp.lang.cobol)
  • Re: Get/Set vs Public Variables
    ... string firstname; ... EVER will need any functionality in getters and setters for the two string ... For example, if this was your typical business object, the name and last ...
    (microsoft.public.dotnet.languages.csharp)
  • Need expert advice on parsing a string into java beans
    ... I am having a hard time using recursion to parse the string back to the Java beans. ... private String address; // Setters and Getters} ...
    (comp.lang.java.programmer)
  • Re: Get/Set vs Public Variables
    ... string firstname; ... EVER will need any functionality in getters and setters for the two string ... databinding that it can bind only to properties and not to variables. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Get/Set vs Public Variables
    ... string firstname; ... EVER will need any functionality in getters and setters for the two string ... It is better to have the data provider ensure proper data states. ... several placed, e.g. in the GUI, sometimes in the DAL etc. ...
    (microsoft.public.dotnet.languages.csharp)

Quantcast