Tell, Don't Ask

Tell an object what to do instead of pulling its data out and deciding for it.

What is Tell, Don't Ask?

Tell, don't ask means telling an object what to do instead of pulling its data out and deciding for it. The object that owns the data should own the decision.

// Asking
if (account.Balance >= price) account.Balance -= price;

// Telling
account.Withdraw(price);

Level: Freelancer · More OOP terms at this level

Updated