Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-4015

qpid.packer.Packer implements abstract methods incorrectly.

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Python Client
    • Labels:

      Description

      qpid.packer.Packer implements abstract methods incorrectly. Specifically, it uses the method suggested here. 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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tsally Tim Sally
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: