[Tutor] Public, private and protected member variables.
Alan Gauld
alan.gauld at blueyonder.co.uk
Tue Oct 21 17:54:48 EDT 2003
> Once I start grabbing attributes, I can go overboard.
> A simple example: build a formatted string for a
> customer record by writing code that grabs cust.firstname
> and cust.lastname and so on. The better approach is
> to have a customer method that returns the formatted string.
A good example, Lloyd, of getting the object to do it to itself
so that there is no need for the get/set methods or direct
access to the fields.
> Then the logic is written once and placed where you would
> expect to find it.
Exactly so - inside the class with the data it manipulates.
Thanks for posting,
Alan G.
More information about the Tutor
mailing list