note 84537 added to language.oop5.interfaces

From: Date: Thu, 17 Jul 2008 21:17:53 +0000
Subject: note 84537 added to language.oop5.interfaces
Groups: php.notes 
Request: Send a blank email to php-notes+get-141639@lists.php.net to get a copy of this message
Makes them useles a bit. I give an example: I have a class that enumerate (so implements iterator) a interface that has method key() that returns key for the enumerated object. I cannot implement iterator, that enumerates the objects by itself (so current() returns this), because of collision of method key(). But it's not collision - the key in the iterator and the key in the enumerated object has the same meaning and allways returns same values. (Common example of this iterator is iterator, that reads from database - make a special object for each row is waste of time). Yes - there are workarounds - e.g. rewrite the code so current don't return this - but it's in some cases waste of processor time. Or I can rename the method key in enumerated object - but why should I wrote the same method twice? It's either waste of time (if the function key is simply duplicated) or waste of time (if the renamed key calls original key). Well, the right, clear way there would be to redefine interface iterator -- move the method key to the ancestor of iterator, and makes the ancestor ancestor of enumerated interface too. But it's (with built-in interfaces) impossible too. ---- Server IP: 217.160.250.20 Probable Submitter: 83.208.108.2 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.interfaces.php Edit -- https://master.php.net/note/edit/84537 Del: integrated -- https://master.php.net/note/delete/84537/integrated Del: useless -- https://master.php.net/note/delete/84537/useless Del: bad code -- https://master.php.net/note/delete/84537/bad+code Del: spam -- https://master.php.net/note/delete/84537/spam Del: non-english -- https://master.php.net/note/delete/84537/non-english Del: in docs -- https://master.php.net/note/delete/84537/in+docs Del: other reasons-- https://master.php.net/note/delete/84537 Reject -- https://master.php.net/note/reject/84537 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141639) next »