On Wed, Oct 15, 2003 at 03:03:06PM +0200, Lars Gullik Bjønnes wrote: > Andre Poenitz <[EMAIL PROTECTED]> writes: > > | On Wed, Oct 15, 2003 at 01:52:31PM +0200, Lars Gullik Bjønnes wrote: > >> Free functions should ideally not access class variables, > > > | This assumes that the class is not a random collection of individual > | thing - which it is in our case - but "something real". > > then perhaps each of them should be its own singleton?
Or a static variable in a namespace. *eg* > >> the functions should be free only when they don't need access to the > >> class variables and only need the class's public interface for > >> implementation. (and then of course no class variables should be > >> public.) > > > >> This is the encapsulation part. (or course this can be simulated with > >> anon namespaces, but then the design is more "open" and access to the > >> variables are not as controlled.) > > > | Handing out non-const refs to members is completely destroying the type > | of encapsulation you speak of here ("access"). > > Only in part. It is _exactly_ the same whether I have a reference to a member of a singleton or whether I have a reference to some static variable in some namespace. There is not a wee bit more encapsulation on the class side. > | The two things are functionality-wise completely equivalent. > > > > | But: In the class solution you have to show private members like > | 'last_files_' in the .h, whereas in the namespace solution they are > | hidden in the .C. So this is better encapsulation of the "visibility" > | type. > > The class solution for this is pimpl. I have been waiting for this one. We'd better stop now. Andre'