You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Tim Sally (JIRA)" <ji...@apache.org> on 2012/05/23 01:16:41 UTC

[jira] [Commented] (QPID-4015) qpid.packer.Packer implements abstract methods incorrectly.

    [ https://issues.apache.org/jira/browse/QPID-4015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13281296#comment-13281296 ] 

Tim Sally commented on QPID-4015:
---------------------------------

As a general note, this is the first patch of what I hope to be many as a part of an effort to improve the Python client library. I'm really interested in feedback both on the proposed changed and the process I used to suggest it!
                
> qpid.packer.Packer implements abstract methods incorrectly.
> -----------------------------------------------------------
>
>                 Key: QPID-4015
>                 URL: https://issues.apache.org/jira/browse/QPID-4015
>             Project: Qpid
>          Issue Type: Improvement
>          Components: Python Client
>            Reporter: Tim Sally
>            Priority: Minor
>         Attachments: 0001-Use-abstract-base-class-to-implement-qpid.packer.Pac.patch
>
>
> qpid.packer.Packer implements abstract methods incorrectly. Specifically, it uses the method suggested [here|http://norvig.com/python-iaq.html]. When an abstract method is called, the invalid name _abstract_ results in a NameError exception. The merits of this approach, along with the other most common approaches, are summarized in the table below
> ||Method||||Stops Execution||Stops Execution at Object Creation||Sensible Exception Name||
> |_abstract_ keyword|yes|no|no|
> |raise NotImplementedError|yes|no|yes|
> |Abstract Base Classes|yes|yes|yes|
> Using _abstract_ is not preferable because a NameError does not make immediately clear what is going on. Raising a _NotImplementedError_ exception is a great alternative because the exception name is logical. However, even better is the use of Abstract Base Classes (ABCs). ABCs raise an exception at object instantiation, whereas the other two methods do not result in an exception until an abstract method is called.
> As an example, consider qpid.codec010.Codec. It is not immediately clear this class should not be used. And indeed, it is not used anywhere. Rather, qpid.codec010.StringCodec is the only class in qpid.codec010 meant to be used directly. Using an abstract base class prevents qpid.codec010.Codec objects from being created.  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org