Why Strings as Classes?

Dee Girl deegirl at noreply.com
Wed Aug 27 15:24:50 PDT 2008


Derek Parnell Wrote:

> On Wed, 27 Aug 2008 17:08:47 -0400, Nick Sabalausky wrote:
> 
> > The way I see it, encapsulation is all about the black box idea. And the 
> > only things you can see from outside the black box are the inputs and 
> > outputs. 
> 
> Well said. 

I am sorry I will say my opinion. This sounds good but is simplistic. Black box is good in principle. But it assume you found right interface for the black box. If you define bad interface you have a bad black box. Also please remember that iterator is black box also. But it defines right interface.

> > Indexing: Return the element at position N.
> > Find: Return the position of the element that is equal (value-equal or 
> > identity-equal, depending on the find) to X .
> 
> Exactly.
> 
> > So if there's a function that returns the element at position N and you call 
> > it "find" just because of the *internal implementation* of the function is 
> > an incrementing loop, I consider that to be both a violation of 
> > encapsulation (because the name has been chosen based on the inner workings 
> > of the function, not it's input-output relationship) and a violation of the 
> > definitions.
> 
> Not to mention just plain confusing.

I am confused to. Why is making [] do find good and making find do [] wrong? How do you make decision? To me it looks the opposite way. Because find is less demanding contract than []. In design a stronger contract can replace a weaker contract. Not the inverse. Thank you, Dee Girl



More information about the Digitalmars-d mailing list