Evilness object oriented approach in Morph
David P Harris
dpharris at telus.net
Tue Jan 24 19:38:21 UTC 2006
Andreas Raab wrote:
> Michael Rueger wrote:
>
>> Hilaire Fernandes wrote:
>>
>>>> I hear this argument over and over again, but I tend to disagree about
>>>> its "evilness". After all, OO is all about *encapsulation*
>>>> therefore you
>>>> shouldn't really care about whether a class accesses its *own*
>>>> iVars via
>>>> messages or directly. It is only when subclassing comes into play that
>>>> this causes problems, and perhaps, just perhaps, subclassing is at the
>>>> root of that evilness? After all it's the subclasses that try to
>>>> "extend" (some might say "violate") the well-defined behavior of its
>>>> superclass.
>>>
>>>
>>> Yes, you are right this cause trouble only when I need to extend
>>> some of
>>> the behavior of some attributes. For example, I need a polygon
>>> border to
>>> behvave a bit differently depending on the context of the application.
>>> But as usual there are workaround and different way to do one think.
>>
>>
>> I actually disagree. Encapsulation to me also means that you
>> shouldn't know if a value is in an iVar or computed. Refactoring to
>> change the use from an iVar to something computed or delegated is a
>> hell of a lot easier when using message sends. And the almost done
>> jitter will inline the return inst vars anyway, won't it? ;-)
>
>
> Actually, I don't buy the "you shouldn't know" argument one bit :-)
> Must be because I've been dealing with security stuff too much lately.
> In security the answer is "no, you shouldn't know - you MUST know"
> precisely what is an iVar and how it is exposed where. So clearly "you
> shouldn't know" is not a universal principle but rather comes from a
> certain design point of view - namely what I would call "design for
> extensibility" in which one tries to make the classes so that it is
> easy to reuse and extend them. Which is a very worthwhile goal, but
> even from this point of view it's not really "you shouldn't know" -
> it's really "you should use accessors so that it's easy to extend by
> subclasses" and that therefore, again, in your own code you really
> *should* know that you are using accessors for the sake of later
> extensibility.
>
> Cheers,
> - Andreas
Uh? I thought he meant "you shouldn't know" from *outside* the
encapsulation. Obviously from inside you should know what is what. I
think you two actually agree.
David
More information about the Squeak-dev
mailing list
|