[interfacekit] Re: BRoster & BWindow

Hi Adi,

It looks like we agree in all but one point of the discussion, so I 
take the liberty and remove all "unused" parts of the discussion :-)

"Adi Oanca" <e2joseph@xxxxxxxxxx> wrote:
> > Direct member access is a major pain in every class library you 
> > write.
>     YES, it is! ... when you are in public area !

Not only that, because...

> > It's just so easy and nice that everybody does it for small (or his
> > own) classes.
> > It's not recommendable for a public and huge API like the BeAPI is.
>     Let me say that, I do agree with that affirmation! But, ( there 
> always
> is a but. :-) it does not always apply! I cannot use an private 
> accessor
> classes between BWindow an BView! It complicates things! It is 
> BWindow who
> manages some of BView's members; BView only access them(I don't know 
> for
> sure now, but I think there are some members that BView doesn't even 
> read or
> write!).

... classes don't stay the same. They are constantly changing and 
evolving. Sure, with direct member access, you can write a perfectly 
working API.
But it won't be less flexible and not as easy to understand when you 
actually have to change anything. Suddenly, you change values in places 
where it's not allowed to do, or you free an object although you 
mustn't anymore, or you just change one value but don't update another 
which depends on it.
That's all solvable, but using accessor methods, you save much headache 
later on. Sometimes even in the original implementation.

> PS: an example! This I consider poor design:
> 
> class BRoster{
> private:
>     friend RosterPrivate;
> }
> 
> class RosterPrivate{
> private:
>     friend BWindow;
>     void UpdateActiveApp(...){
>         roster->UpdateActiveApp(...) // that's all !!!
>     }
> }
> 
> What is point in that=3F=3F=3F The same would go for a LOT of 
> BWindowInternals
> methods, if implemented!

How else would you do it=3F
A private friend accessor class has the advantage of hiding the 
implementation and doesn't export class internal functions to the 
outside.
Although it's not that convenient when implementing the class, and it 
doesn't look that nice either, it definitely has some advantages, that 
should outweigh the disadvantages (in comfort).

Adios...
   Axel.


Other related posts: