From dc60c4eb0021a5aa321bd1a9b96f33d278ce7744 Mon Sep 17 00:00:00 2001 From: Ahmed Adel Date: Mon, 20 Oct 2025 09:46:25 +0300 Subject: [PATCH] Add content: Tell Don't Ask principle in Software Design roadmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added comprehensive explanation of Tell Don't Ask principle with examples. Fixed @article tag capitalization. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../tell-dont-ask@0rGdh72HjqPZa2bCbY9Gz.md | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/data/roadmaps/software-design-architecture/content/tell-dont-ask@0rGdh72HjqPZa2bCbY9Gz.md b/src/data/roadmaps/software-design-architecture/content/tell-dont-ask@0rGdh72HjqPZa2bCbY9Gz.md index 72905b54a..ed7ac738d 100644 --- a/src/data/roadmaps/software-design-architecture/content/tell-dont-ask@0rGdh72HjqPZa2bCbY9Gz.md +++ b/src/data/roadmaps/software-design-architecture/content/tell-dont-ask@0rGdh72HjqPZa2bCbY9Gz.md @@ -1 +1,28 @@ -# Tell, don't ask \ No newline at end of file +# Tell, Don’t Ask + +The Tell, Don’t Ask principle emphasizes that objects should be told what to do rather than being queried for their state and having decisions made externally. This promotes encapsulation and reduces coupling by keeping logic within the objects that own the data. + +## Key Concepts + +- Instead of pulling data out of objects to make decisions, push the behavior into the object itself. +- Objects should be responsible for their own logic and state management. + +Asking style (bad): + +``` +if (user.profile.isComplete()) { + // allow checkout +} +``` + +Telling style (good): + +``` +if (user.canCheckout()) { + // allow checkout +} +``` + +Learn more from the following resources: + +- [@article@Tell, Don't Ask](https://martinfowler.com/bliki/TellDontAsk.html)