Tim Sally created QPID-4015:
-------------------------------
Summary: 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: [email protected]
For additional commands, e-mail: [email protected]