Re: Are ABCs an anti-pattern?

Discussion in 'Python' started by Terry Reedy, Oct 2, 2012.

  1. Terry Reedy

    Terry Reedy Guest

    On 10/2/2012 10:23 AM, Demian Brecht wrote:
    > I don't use them anymore, but I'm curious about others opinions on this
    > list...
    >
    > The more time I spend in Python, discovering what "Pythonic" code is and
    > such, it seems that I throw away much in terms of academic learnings as
    > far as "OOP correctness" goes. In doing so, I find that, in general,
    > overall LOC (yes, I'm aware that this is a poor metric to judge anything
    > on), readability and overall quality of code seems to go up. Yes, you
    > give the user much more rope to hang themselves with making the general
    > assumption that the user knows what they're doing, but we're all
    > consenting adults here after all, right? ;)
    >
    > As an example, I initially had an OAuth 2.0 client library that was
    > roughly 450 LOC (using ABCs, adapter patterns for the various flows,
    > etc). Dropping this for a more "Pythonic" (at least, what my
    > interpretation of Pythonic code is) brought the entire library down to
    > 55 LOC. Having said that, the decline in LOC and overall grok-ability
    > wasn't entirely due to moving away from ABCs and dropping the use of
    > adapters, but it did have quite a bit to do with it).
    >
    > As such, I see ABCs as somewhat of an anti-pattern in the Python world.
    > The concept is obviously essential in non-duck-typed language using
    > strict OOP, but does it *really* belong in Python?


    ABCs were added (fairly recently) in 3.0 for the reasons given in
    http://python.org/dev/peps/pep-3119/
    It was expected that it would take awhile for them to see good, pythonic
    uses. We obviously did okay without them up to 2.7.

    They are partly informational, partly meant to help duck typing. I don't
    think they are used much in the stdlib (except to register classes) and
    I have not used them myself.

    --
    Terry Jan Reedy
     
    Terry Reedy, Oct 2, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Rae
    Replies:
    0
    Views:
    640
    Mark Rae
    Mar 7, 2006
  2. Antti S. Brax

    Name that anti-pattern

    Antti S. Brax, Sep 29, 2005, in forum: Java
    Replies:
    15
    Views:
    893
    Chris Smith
    Sep 30, 2005
  3. Demian Brecht

    Are ABCs an anti-pattern?

    Demian Brecht, Oct 2, 2012, in forum: Python
    Replies:
    0
    Views:
    191
    Demian Brecht
    Oct 2, 2012
  4. Trent Nelson

    Re: Are ABCs an anti-pattern?

    Trent Nelson, Oct 5, 2012, in forum: Python
    Replies:
    0
    Views:
    195
    Trent Nelson
    Oct 5, 2012
  5. Demian Brecht

    Re: Are ABCs an anti-pattern?

    Demian Brecht, Oct 6, 2012, in forum: Python
    Replies:
    0
    Views:
    246
    Demian Brecht
    Oct 6, 2012
Loading...

Share This Page