note 73380 added to language.oop5.interfaces

From: Date: Tue, 20 Feb 2007 21:20:56 +0000
Subject: note 73380 added to language.oop5.interfaces
Groups: php.notes 
Request: Send a blank email to php-notes+get-123612@lists.php.net to get a copy of this message
albert: Of course that doesn't work; it would violate the Liskov substitution principle. Namely: If Cmyqueue is-a Iqueue, then I must be able to do with an Cmyqueue anything I can do with an Iqueue. If I can call enqueue() on Iqueue passing any Object, I must be able to do the same with Cmyqueue. Restricting Cmyqueue::enqueue() to accept only a subclass of Object would break this. That's why generics (in languages supporting them) don't work like this: a List<String> cannot be "properly" converted to a List<Object>, because you can add Objects to a List<Object> but a List<String> should never contain Objects that are not Strings. ---- Server IP: 66.207.199.35 Probable Submitter: 64.180.161.38 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.interfaces.php Edit -- https://master.php.net/note/edit/73380 Del: integrated -- https://master.php.net/note/delete/73380/integrated Del: useless -- https://master.php.net/note/delete/73380/useless Del: bad code -- https://master.php.net/note/delete/73380/bad+code Del: spam -- https://master.php.net/note/delete/73380/spam Del: non-english -- https://master.php.net/note/delete/73380/non-english Del: in docs -- https://master.php.net/note/delete/73380/in+docs Del: other reasons-- https://master.php.net/note/delete/73380 Reject -- https://master.php.net/note/reject/73380 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123612) next »