Alex Martelli, Uber Technical Lead, Google, Inc.
Date: Thursday, July 29
Time: 11:35am - 12:20pm
The classic "Gang of 4" repertory of Design Patterns includes several Structural ones (Adapter, Bridge, Decorator, Facade, Proxy), which deal with masquerading and/or adaptation -- objects "posing as," "fronting for," "proxying for," "adapting to" other objects or interfaces.
The special characteristics of Python, just as for other design patterns, warrant special considerations for DPs in this category: this talk surveys the issues and gives examples.
Some patterns not covered in the Gang of 4 book are also worthy of consideration. One such DP is "currying," i.e., in the general sense, the adaptation of a callable to a different required call-signature, mostly for "call-back" purposes. This talk illustrates both specialized and general-purpose Python approaches to supplying and utilizing currying.
A more general, _infrastructural_ approach to object/interface adaptation issues is "protocol adaptation," proposed in PEP 246, and implemented in various ways in existing Python extensions, for example in the PyProtocols package and in the Twisted framework.
Protocol Adaptation allows up to four separate groups of designers (authors of (a) some protocols [interfaces] which need to be used, (b) some objects that may not fully implement the functionality required by (a), (c) adapters of (b) to (a), and (d) application level code) to cooperate with maximally lax coupling, and particularly without needing to "invade" (modify) other existing code for the purpose.
Download presentation file