tda

Refactor Python code to enforce Tell, Don't Ask encapsulation.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/messeb/skills --skill tda
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tda
Source: https://github.com/messeb/skills/tree/main/plugins/general-developer/skills/tda
Command: npx skills add https://github.com/messeb/skills --skill tda

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the "Tell, Don't Ask" (TDA) principle in object-oriented programming, preventing anemic domain models and promoting encapsulated behavior.

Core Features & Use Cases

  • Encapsulates Logic: Moves decision-making and state manipulation logic inside the objects themselves, rather than exposing internal state for external code to act upon.
  • Improves Readability: Leads to cleaner, more intuitive client code that issues commands rather than querying state and orchestrating complex logic.
  • Use Case: Instead of an external function checking an order's status and then updating it, the Order object itself has a confirm() method that handles all internal state transitions and validations.

Quick Start

Use the tda skill to refactor the provided Python code snippet to follow the Tell, Don't Ask principle.

Frequently Asked Questions about tda

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the Tell Don't Ask principle in object-oriented programming?

The Tell Don't Ask principle in object-oriented programming mandates passing commands to objects rather than querying their state to make external decisions. It enforces encapsulation by moving decision-making logic inside the object itself to prevent anemic domain models.

How do I refactor code to fix feature envy and train wrecks?

Refactor feature envy and train wrecks by moving decision-making and state manipulation logic inside the relevant objects. Instead of chaining external method calls to query state, encapsulate the behavior by telling the object to perform the action directly.

How do I prevent anemic domain models in OOP?

Prevent anemic domain models in OOP by encapsulating behavior within your objects. Move state checks and mutations out of external client code and into the object's own methods to ensure it manages its internal data and transitions entirely.

Why does external state checking before mutation violate encapsulation?

External state checking before mutation violates encapsulation by exposing an object's internal data for external orchestration. This creates temporal coupling and anemic models, preventing the object from managing its own state transitions and validations internally.

When should I move decision-making logic inside an object?

Move decision-making logic inside an object when external code queries its state to perform actions, causing direct public field mutation or feature envy. This refactoring step encapsulates behavior and eliminates temporal coupling.

Can I use this refactoring approach for Python code?

Yes, you can use this approach to refactor Python code. It guides you to transform external state checks into encapsulated methods, such as replacing external status validations with a dedicated confirm method that handles internal state transitions.