Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2004-05-23 17:56:27

> >> If you are making designs that would normally have a lot of getters
> >> and setters, it suggests that they may have an insufficient level of
> >> abstraction. Of course, that isn't neccessarily the case -- but it
> >> does seem to be the rule in my code. I personally don't have a need
> >> for this facility and I don't think I want a library that would
> >> encourage that style.
> >
> > I don't see what getters and setters have to do with levels of
> > abstraction. Needless to say I see nothing wrong with the style
> > that uses properties, but since you didn't say what bothers you
> > about that style I can't answer for why you don't like it. Care to
> > explain ?
> When classes have a lot of getters and setters or, equivalently,
> exposed properties that are just reflections of underlying data
> members, they usually represent just a collection of exposed data
> values rather than a higher level of abstraction.

I agree. And in my expirience I from time to time need exactly something
like this. I just need objects of class A have property (string p_type for
example). I coud make it just public member std::string p_type. But this
would allow anybody by mistake change it. So what I want is readonly
property, that would be as close as possible to unsafe public member
definition. class_property family of templates serve this purpose. It's not
about should or should you not provide a direct access to the class members.
It how to facilitate it. Wherther or not it's good design is a bit separate
question. IMO it depends on situation and I found in many case good
application for properties with very sound design.


Boost list run by bdawes at, gregod at, cpdaniel at, john at