On Fri, 2005-02-18 at 20:04, Richard Hughes wrote:
A few things to talk about, in no particular order:
- Do we disapprove of public member variables, even where there's no
disadvantages to using them?
There are always disadvantages in the long term (wrt maintainence at least), for most classes.
Modifications to public member variable declarations unavoidably create widespread ripples during refactoring, whereas with methods you can always write wrappers to preserve the old interface temporarily.
You should always plan on your classes getting refactored someday; no matter how well-designed they are, requirements will always change.
I learned this lesson the hard way in Inkscape. Wrapping existing public member variables in accessor methods was the ONLY way I could successfully perform many of the major refactorings I've done in our codebase.
Otherwise, I was forced to perform far too much radical change, all at once. Trying to bite off too much at once almost always meant having to scrap what I was doing and start over again.
That's not to say public member variables are _always_ bad. Basically, classes fall into three categories:
1) "interface" classes, which have mostly abstract or very thin wrapper methods, and no data to speak of at all.
2) "implementation" classes, whose member variables ought to be private or (occasionally) protected.
3) "data" classes, whose member variables can and ought to be public; these classes hold locally useful data and should only have trivial methods if any (often a constructor to prefill/initialize fields is desirable).
The latter type of class ("data") are used mostly for local, internal things.
In reality things aren't quite so cut-and-dried, but that is at least the Platonic ideal I would like us to strive for.
- The coding style guide doesn't mention the how the names of
enumerations should be formatted.
The enumeration type name should be formatted the same as class names, the names of individual enumeration values ought to be all caps and use underscores for word separators, as I believe the coding style document specifies for constants.
- Likewise the xml:space attribute. The difficulty with moving this
is that you could cause roundtripping problems. Can we even do roundtripping?
Ideally we should be able to. I'm not sure how well we currently do in that regard though.
-mental