Re: case-insensitive strings
Re: case-insensitive strings
- Subject: Re: case-insensitive strings
- From: Ondra Cada <email@hidden>
- Date: Thu, 10 Oct 2002 19:36:40 +0200
On Thursday, October 10, 2002, at 06:48 , Matt Neuburg wrote:
I didn't get any useful answers. The thing that amazes me is that no one
chimed in with outraged cries of how the NSString model is inadequate.
That might be since it is not, perhaps? ;)
Doesn't this bother anyone else out there besides me?
Nope, since it is an artifical hurdle made up by you: you take the OO
design wrong, and thus naturally get wrong answers.
This thing is an
object; the whole point of having an object is that the knowledge of how
to
do stuff, such as decide whether two instance are "equal", should be made
to reside in the object.
Right.
The problem is that a string is a string is a string; "John" is not the
"john", and that's that -- at the level of string itself. No more, no less.
The idea that you can't flip case sensitivity on
or off for an individual string instance is just nutty to me.
Nutty it would be if you could. Since, there's no such thing as a
"case-insensitive string". Of course, there might be a code level *above*
which *uses strings* and which says "Yeah, in these conditions I want not
to distinguish them by case" -- that is exactly what others pointed out to
you.
The important thing is that it is *ANOTHER CODE LEVEL ABOVE STRINGS*. To
force its functionality into the string class itself would be just a very
bad OO design: nutty.
I do it, but I also do a lot of barfing.
Well if you insist, ObjC is flexible enough for you: do add an
NSCaseInsensitiveString concrete subclass to the NSString cluster. Do
reimplement isEqualToString: at the NSString base level (probably using a
category, with the cluster it might need some experimenting) so that if
either the receiver or the argument are NSCaseInsensitiveStrings, they
would be compared case insensitively. Do use the thing in your code
extensively...
...and you'll find yourself barfing much much more, as soon as the bad OO
design lifts its ugly head and bites you hard ;)
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.