in reply to (my?) problem with re-blessed references(?)
I also shy away from using lvalued accessors. They are great for examples, as they don't take much space (screen space is a commodity when presenting), but they are awkward in practise. You can't easily intercept the passed in value, so masking such a method is hard.
You don't have to have set_x, get_x accessors - a common way is to have a single accessors that sets an attribute if it gets an argument, and gets it if there isn't one.
But I'm not a big users of accessors. For me, objects are more than a bunch of values with a ribbon around them. If I want just a bunch of attributes, I'd use something struct-like - for instance, a hash. For me, an object is a thing that keeps state. Attributes are used to record the state; methods are used to transit from one state to another.
Abigail
|
---|