[Python-Dev] Re: PEP 246: LiskovViolation as a name

Skip Montanaro skip at pobox.com
Wed Jan 12 02:39:00 CET 2005


    >>> Terminology point: I know that LiskovViolation is technically
    >>> correct, but I'd really prefer it if exception names (which are
    >>> sometimes all users get to see) were more informative for people w/o
    >>> deep technical background.  Would that be possible?
    >> 
    >> I don't see how. Googling on Liskov immediately brings up clear and
    >> understandable descriptions of the principle that's being violated.
    >> I can't imagine summarizing the issue more concisely than that! What
    >> would you suggest? Including better explanations in the documentation
    >> is a must, but "LiskovViolation" in the exception name seems
    >> unbeatably clear and concise.

    David> Clearly, I disagree.

I had never heard the term before and consulted the Google oracle as well.
I found this more readable definition:

    Functions that use pointers or references to base classes must be able to
    use objects of derived classes without knowing it.

here:

    http://www.compulink.co.uk/~querrid/STANDARD/lsp.htm

Of course, the situations in which a Liskov violation can occur can be a bit
subtle.

    David> My point is that it'd be nice if we could come up with an
    David> exception name which could be grokkable without requiring 1)
    David> Google, 2) relatively high-level understanding of type theory.

I suspect if there was a succinct way to convey the concept in two or three
words it would already be in common use.  The alternative seems to be to
make sure it's properly docstringed and added to the tutorial's glossary:

    >>> help(lv.LiskovViolation)
    Help on class LiskovViolation in module lv:

    class LiskovViolation(exceptions.Exception)
     |  Functions that use pointers or references to base classes must be
     |  able to use objects of derived classes without knowing it.
     |  
     ...

I suspect there's something to be said for exposing the user base to a
little bit of software engineering terminology every now and then.  A couple
years ago I suspect most of us had never heard of list comprehensions, and
we all bat the term about without a second thought now.

Skip


More information about the Python-Dev mailing list