The Eric Normand Podcast

What is a total function?

8 snips
Sep 2, 2019
Explore the fascinating concept of total functions and their critical role in robust programming. Discover how they enhance reliability by preventing errors compared to partial functions. Gain insights into strategies and examples that can help programmers ensure function totality, creating more dependable code. It's a deep dive into the building blocks of programming that guarantees smoother operations.
Ask episode
AI Snips
Chapters
Transcript
Episode notes
INSIGHT

Total Functions

  • A total function returns a value for every valid input, increasing robustness by preventing runtime errors.
  • Valid arguments are defined by type annotations in typed languages or informal rules in untyped languages.
ANECDOTE

Partial Functions: Division Example

  • Division is a classic example of a partial function because dividing by zero causes errors.
  • This highlights how partial functions compromise robustness, leading to potential production failures.
ANECDOTE

Partial Functions in OOP

  • A Person class with salary method, but Volunteer subclass throws exceptions demonstrates partial functions.
  • This violates the principle of substitutability and indicates potential design flaws.
Get the Snipd Podcast app to discover more snips from this episode
Get the app