Type hinting was: Constructive Criticism/Venting

Jan Schneider <[email protected]>
Newsgroups gmane.comp.horde.devel
Message-ID <[email protected]>
Zitat von Michael J Rubinsky <[email protected]>:

> Quoting Michael M Slusarz <[email protected]>:
>
>> * Type hinting is not tremendously useful, and in fact can be a  
>> hinderance.  Example: we were noticing that Horde_Imap_Client, when  
>> unserialized in IMP (which will happen on every access except  
>> logins), would recreate a cache object that would be entirely  
>> separate from the global Horde object.  To get around this, I  
>> decided to use the old wrapper trick - create a wrapper library  
>> that does nothing more than have access to the global instance when  
>> unserialized.  This can/should be accomplished without doing  
>> something like having to extend the entire Horde_Imap_Client_Cache  
>> class.  However, due to type hinting, this wasn't possible.  This  
>> calls into doubt the usefulness of type hinting.  Especially since...
>
> I agree it can be a pain and require some workarounds, but it allows  
> us to enforce a method's contract without having to add a poor-man's  
> type checking using if/typeof clauses. I guess it's a matter of  
> which trade off is more important to us.

I agree that's a trade-off, but I tend with Michael R. that enforcing  
the contract makes APIs much clearer, and coding more disciplined. The  
difficult places can often be solved by using interfaces as typehints.

-- 
Jan Schneider
The Horde Project
http://www.horde.org/
https://www.facebook.com/hordeproject

-- 
dev mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.