--
The only way to go fast is to go well.
---
You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discu...@googlegroups.com.
To post to this group, send email to clean-code...@googlegroups.com.
Visit this group at http://groups.google.com/group/clean-code-discussion.
I've used this exact pattern when doing the (extended) FizzBuzz kata.
It somehow feels a little clunky, but I've never been able to pin down why. Your elucidation helps I think. I'll do the kata again and see if I think of anything.
Cheers
Karl
--
interface Identifiable { public function getId(); public function setId( Id $id );}
I think that there is a misunderstanding of what interfaces are.If you want to use an interface properly, you need to typehint everything.Like this :
interface Identifiable {public function getId();public function setId( Id $id );}
<?phpinterface Identifiable {/*** @return Id*/public function getId();}class Kitten implements Identifiable {private $kittenId;public function getId(){return $kittenId;}/*** @param KittenId $id*/public function __construct( $id ) {if ( !( $id instanceof KittenId ) ) {throw new InvalidArgumentException( 'Needs to be a KittenId' );}$kittenId = $id;}}class Pony implements Identifiable {private $ponyId;public function getId(){return $ponyId;}/*** @param PonyId $id*/public function __construct( $id ) {if ( !( $id instanceof PonyId ) ) {throw new InvalidArgumentException( 'Needs to be a PonyId' );}$ponyId = $id;}}abstract class Id {public abstract function toString();}class KittenId extends Id {// Makes sure all Kitten ids start with a "k"}class PonyId extends Id {// Makes sure all pony ids start with a "p"}
--