Gathering Related Functionality: Patterns for Clean API Design (Paul Ganssle)

Sdílet
Vložit
  • čas přidán 15. 06. 2019
  • This talk will arm you with some tools to design a library that 'just works', but also has obvious escape hatches to handle corner cases. It covers several patterns for cleanly organizing related and overlapping functionality in a way that statisfies both humans and static analysis tools.
    ---
    What do you do when you have to choose between designing your function for one of two common use cases?
    How about when the same logical operations (say, multiplication or concatenation) need to have different implementations depending on the type of the arguments they are applied to?
    These kinds of questions can be vexing when trying to design a clean, well-scoped API.
    This talk will cover several strategies for grouping related functionality in a way that presents a logically clean interface to both humans and static analysis tools like type checkers and document generators.
    This talk covers:
    Alternate constructors with @classmethod
    Inheritance with @staticmethod and @classmethod
    Dispatch by type
    A new convention for namespacing functions: variants
    About the Author
    Paul Ganssle is a software developer at Bloomberg and a maintainer of several open source libraries including dateutil and setuptools, and a contributor to many other FOSS projects.
    Talk page: 2018.pycon.ca/talks/talk-PC-5...
    Author website: ganssle.io
  • Věda a technologie

Komentáře •