in reply to Re^9: Perl OO and accessors
in thread Perl OO and accessors
An attribute is essentially a variable with possibly some runtime enforced restrictions so it should be accessible just like any other variable.
That is needlessly restrictive, and the conclusion does not follow from the premise. Suppose you have a timer that is counting up/down. You may have, as an "attribute", the elapsed time/time remaining. Should that look like a variable? Or should I call a function to retrieve that data? Suppose the data isn't actually stored in the object, but is an external resource?
Yes, it can be aestheticly pleasing to be able to write code that avoids overt function calls, but the flip side is that you then have derived attributes that look different from innate attributes, or you have to maintain the derived attributes in sync with changes to the innate attributes, further confusing the matter. I take it to be somewhere between "better" and "no worse" to have to make explicit method calls to set/get attribute-like properties of an object.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: Perl OO and accessors
by fergal (Chaplain) on Nov 30, 2005 at 00:17 UTC | |
by herveus (Prior) on Nov 30, 2005 at 15:30 UTC | |
by fergal (Chaplain) on Nov 30, 2005 at 16:42 UTC | |
by Perl Mouse (Chaplain) on Nov 30, 2005 at 21:13 UTC | |
by fergal (Chaplain) on Dec 01, 2005 at 00:58 UTC |