Slide 1
Slide 1 text
3/17/13 API Design for Libraries
file://localhost/Volumes/Untitled/Uploaded/apidesign/presentation.html 1/16
API Design for Libraries
Authors: Chris McDonough
Agendaless Consulting
Date: 03/15/2013 (PyCon 2013)
Who Am I
Came to Python via Zope in 1999. Worked at Digital Creations (aka Zope Corporation) until 2003. Now a
consultant with Agendaless Consulting.
Primary author of Pyramid web framework, Supervisor UNIX process control system, Deform form
system, Repoze collection of middleware, and other unmentionables. Contributor to Zope, WebOb, and
other OSS projects.
I Care About Your Feelings
During this talk, I call out antipattern examples from actual projects, including my own.
If I use code from one of your projects as an antipattern example, it doesn't mean I don't like you.
This talk is impossible to give without showing negative examples.
I'm lazy and the best negative examples are those that already exist.
Libs, Frameworks, Apps
Application: Maintains lots of state, can use global state with abandon.
Framework: No or little state, but lots of callbacks.
Library: Maintains none or little of its own state, no or few callbacks.
A web framework instance is often fed to a global mainloop, but that doesn't mean it should use globals
with abandon. Even then if the framework doesn't use global state, with a little care, two framework
instances can live in the same process. Some frameworks mutate or require global state (IMO
inappropriately).