interface Shape
{
public function calculateArea();
public function __get($key);
public function __set($key, $value);
}
versus
interface Shape
{
public function calculateArea();
public function getWidth();
public function setWidth($width);
public function getHeight();
public function setHeight($height);
}
It seems that in terms of interfaces, magic getters/setters provide no clear indication as to what the getters and setters are, resulting in an unclear API.
Therefore, if the interface needs all of the getters/setters to be implemented in the classes that implement the interface, what use do the magic methods provide besides saving a few keystrokes?
-Hector
-Hector
On Thu, Jun 4, 2009 at 9:21 AM, Ed Lazor <edlazor@internetarchitects.biz> wrote:
Don't interfaces just provide a list of methods/properties that need
to be defined in any class that implements them? It seems like this
is where you would use the ability to create a class that both extends
another class and implements an interface.
On Thu, Jun 4, 2009 at 9:08 AM, Hector Virgen<djvirgen@gmail.com> wrote:
> In terms of using interfaces, how should __get and __set be used? Should the
> interface require an implementation of the just the magic methods, or just
> the actual get* and set* methods, or both? Or should the magic methods be
> avoided when using interfaces in order to ensure a common interface?
> -Hector
>
没有评论:
发表评论