Code generation is a useful approach for building, maintaining, and distributing code based on the specification of an API, reducing error and enabling automatic updates as the API interface changes. It also allows you to expand your reach at a lower cost and get more code into open source for developers.
Luke Sneeringer walks you through creating targeted, maintainable code generation for APIs. At a high level, every API has the same structure—nouns (messages), verbs (methods), and adjectives (fields)—but everything in your data model is a mandate. He provides a minimalist schema, API -< message -< field and API -< interface -< method and focuses on modeling ontological relationships. Luke’s goal is to design for a world where the output has a different set of maintainers than the schema, and explains why all output-related code should receive the same data—"If you can edit any of the output, you can edit it all with no surprises." You’ll discover why output can be shockingly procedural and why you should rely on tooling for your target ecosystem. But nothing is ever perfectly easy, and there are still challenges. Versioning is hard. Really hard. Release management is hard. How do you communicate what happened? And tools make assumptions, but what happens when those assumptions are broken?
Luke Sneeringer is the author of Professional Python. He’s worked at several companies, including Google, Ansible, and FeedMagnet (which he cofounded). He lives in Boulder Creek, California, with his wife and three cats.
©2019, O'Reilly Media, Inc. • (800) 889-8969 or (707) 827-7019 • Monday-Friday 7:30am-5pm PT • All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners. • email@example.com