Hrm... is it really, though? Consider, what's the actual contract on the base class that derived classes have to adhere to?
Well, if CanRead returns false, calls to Read will throw. If CanRead returns true, Read reads stuff. If CanWrite returns false, calls to Write will throw. If it returns true, Write will write stuff. Etc. You can argue all you want about whether the interface is correctly factored (although the .NET Framework design guidelines book has some very interesting discussion on why the design is the way it is) but I don't think you can really say that it's a Liskov violation. -Chris From: [email protected] [mailto:[email protected]] On Behalf Of Kelly Leahy Sent: Wednesday, March 09, 2011 6:32 PM To: [email protected] Subject: Re: Your Favorite Liskov Violations Examples in .NET The entire way that streams work is an lsp violation, with read/canread.... On Mar 10, 2011 2:29 AM, "Chris Bilson" <[email protected]> wrote: > Favorite? I would't say I like it, but this is the classic: > > ICollection<string> a = new [] { "go ahead and try to add something...after > all, I implement ICollection<>" ]; > a.Add("ha ha!"); > > --c > > > On Wed, Mar 9, 2011 at 16:46, Aeden Jameson <[email protected]> wrote: > >> What are your favorite examples of violations of Liskov in the .NET >> framework? >> >> -- >> Cheers, >> Aeden >> >> Blog : http://aedenjameson.blogspot.com/ >> Linked In: http://www.linkedin.com/in/aedenjameson >> Blah Blah Blah: http://www.twitter.com/daliful >> Facebook : http://www.facebook.com/aeden.jameson >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Seattle area Alt.Net" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected] <mailto:altnetseattle%[email protected]> . >> For more options, visit this group at >> http://groups.google.com/group/altnetseattle?hl=en. >> >> > > -- > You received this message because you are subscribed to the Google Groups "Seattle area Alt.Net" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to [email protected] <mailto:altnetseattle%[email protected]> . > For more options, visit this group at http://groups.google.com/group/altnetseattle?hl=en. > -- You received this message because you are subscribed to the Google Groups "Seattle area Alt.Net" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/altnetseattle?hl=en. -- You received this message because you are subscribed to the Google Groups "Seattle area Alt.Net" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/altnetseattle?hl=en.
