The Tell Don't Ask principle tells us not to manipulate objects conditionally based on their state; instead, the knowledge of when to manipulate belongs in the object. That sounds like a rule about mutability, but it's not: it applies just as well when objects are immutable. This screencast will look at an example of "asking", convert it to a "tell", and examine the role (or lack thereof) of mutation.

Execute Program

Looking for something more interactive? Try Execute Program, an interactive learning platform from Destroy All Software LLC! It has courses on TypeScript, SQL, regular expressions, JavaScript concurrency, and more. All Destroy All Software subscriptions include full access to Execute Program, or you can subscribe to Execute Program directly.