Tesugen

NSCFDate

Malte writes about an NSCalendarDate oddity and when I checked out the docs, I saw that the creation methods are declared to return id instead of objects of the class in which the method is defined. This is clearly against the conventions of Foundation; always when doing [MyThing thingWithString:@"hello"] you would rightly expect to get a MyThing instance back – or at least an object of any class that doesn’t violate the Liskov Substitution Principle (PDF).

The NSCFDate class seems to be a private subclass of NSDate (according to this post), so I don’t understand how this could be consistent with the LSP – for example, if you have added a method in a category to NSCalendarDate, it wouldn’t be invoked if you send the message to what in fact is an NSCFDate instance.

The above was posted to my personal weblog on May 27, 2002. My name is Peter Lindberg and I am a thirtysomething software developer and dad living in Stockholm, Sweden. Here, you’ll find posts in English and Swedish about whatever happens to interest me for the moment.

Posted around the same time:

The seven most recent posts:

  1. Tesugen Replaced (October 7)
  2. My Year of MacBook Troubles (May 16)
  3. Tesugen Turns Five (March 21)
  4. Gustaf Nordenskiöld om keramik kontra kläddesign (December 10, 2006)
  5. Se till att ha två buffertar för oförutsedda utgifter (October 30, 2006)
  6. Bra tips för den som vill börja fondspara (October 7, 2006)
  7. Light-Hearted Parenting Tips (September 16, 2006)
Bloggtoppen.se