Summary of "Cancel All My Appointments • Kyle Simpson • YOW! 2018"
Summary of "Cancel All My Appointments" by Kyle Simpson
In the talk "Cancel All My Appointments" by Kyle Simpson at YOW! 2018, the focus is on the concept of cancellation in asynchronous programming, particularly within JavaScript. Simpson emphasizes that cancellation is not merely an exceptional event but a guaranteed occurrence that should be planned for in software design. He argues for a shift in perspective from viewing cancellation as an unexpected event to understanding it as a predictable state that systems should accommodate.
Key Concepts and Features Discussed:
- Cancellation as a Certainty: Simpson posits that cancellation will inevitably occur in asynchronous operations, and developers should prepare for it rather than treating it as an exception.
- Complexity of Cancellation: He categorizes cancellation into various forms, including:
- Final cancellations (e.g., aborting an operation).
- Temporary pauses and undo actions, which complicate the cancellation model.
- Levels of Abstraction:
- Event-Based vs. State-Based: He critiques the event-driven approach to cancellation, arguing that it can lead to missed events and unpredictability. Instead, he advocates for modeling cancellation as a state that can be observed and managed.
- Collection of States: The ultimate goal is to manage cancellation across a collection of states rather than treating it as an isolated event.
- Practical Implications for Developers:
- Developers should integrate cancellation into all asynchronous operations, including AJAX calls, timers, and database queries, making it a first-class feature in application design.
- He highlights the importance of designing systems holistically to handle cancellation seamlessly.
- cancellation tokens: Simpson introduces the concept of cancellation tokens, which allow for better management of cancellation states across asynchronous operations. This approach is gaining traction in web standards.
- Proposed Solutions:
- He discusses a library he created called "calf" that uses generator functions to provide cancelable asynchronous operations.
- He suggests the idea of "cancellation zones" to manage multiple operations collectively, allowing for better handling of cancellation and state management.
Recommendations for Developers:
- Plan for Cancellation: Treat cancellation as a fundamental aspect of system design rather than an afterthought.
- Use cancellation tokens: Adopt cancellation tokens for better state management in asynchronous operations.
- Think Holistically: Design systems that consider cancellation across all levels of abstraction to avoid unnecessary complexity.
Main Speaker:
- Kyle Simpson: A well-known JavaScript developer and educator, recognized for his contributions to the JavaScript community and author of the "You Don't Know JS" book series.
This talk encourages a paradigm shift in how developers approach cancellation in programming, advocating for a proactive and structured approach to improve software quality and maintainability.
Category
Technology