Re: Commit: More refactoring, bug fixes

From: Mike Nordell (tamlin@algonet.se)
Date: Sat Nov 30 2002 - 02:23:30 EST

  • Next message: Hubert Figuiere: "Re: Commit: More refactoring, bug fixes"

    William Lachance wrote:

    > Hub: m_pFrame in xap_FrameImpl needs to be accessed by its child
    > classes, so it can't just be set to private without giving the children
    > some way of accessing it. I think setting it to protected is a good way
    > of doing so.

    I disagree, strongly. If you _really_ need to do this, keep the data private
    but use the aquaintance idiom. For an example of this, have a look at
    gr_Win32Graphics.h.

    I said it before and I'll probably tell less experienced developers this
    until I die - Data in a "real" class has but one access specification,
    private. Data in just "data" classes or struct (e.g. a Rect) can have the
    access specification "public". Data _never_ (never, ever) is protected. The
    _only_ things that belongs in protected is member functions intended for
    just subclasses to have access to.

    Any "protected" data I consider a bug.

    If you want rationales, feel free to search the archives (possibly paying
    attention to comments by me or Joaquin) or check groups.google.com for e.g.
    comp.lang.c++.moderated.

    /Mike



    This archive was generated by hypermail 2.1.4 : Sat Nov 30 2002 - 02:26:36 EST