Ubiquitous Language is a shared language between developers and domain experts, used consistently in code, conversations, and documentation.
Core Idea
- Same terms used by everyone: developers, domain experts, product owners
- Appears in code (class names, method names, variables)
- Used in conversations and meetings
- Documented in the same terms
- Reduces translation errors and miscommunication
Examples
E-Commerce Domain
Ubiquitous Language: Order, Customer, Product, Cart, Checkout, Payment, Shipment
public class Order // Term everyone uses
{
public void Submit() { } // "Submit an order" - business term
public void Cancel() { } // "Cancel an order" - business term
}
public class ShoppingCart // Not "Basket" if business calls it "Cart"
{
public void AddItem(Product product) { } // Business language
}Banking Domain
Ubiquitous Language: Account, Transaction, Deposit, Withdrawal, Balance, Transfer
public class Account
{
public void Deposit(Money amount) { } // Business term
public void Withdraw(Money amount) { } // Business term
public Money Balance { get; } // Business term
}Implementation
Code Reflects Language
// Good: Uses business language
public class LoanApplication
{
public void Submit() { }
public void Approve() { }
public void Reject(string reason) { }
}
// Bad: Technical language domain experts don't use
public class LoanApplicationRecord
{
public void SetStatus(int statusCode) { }
public void UpdateState() { }
}Methods Named After Business Operations
// Good: Business operations
order.Submit();
payment.Process();
shipment.Dispatch();
// Bad: Generic technical operations
order.Update();
payment.Execute();
shipment.SetStatus(ShipmentStatus.Sent);Benefits
- Developers understand business
- Business understands code structure
- Fewer misunderstandings
- Code documents itself
- Easier onboarding
Related Concepts
- Bounded Contexts - Language boundaries
- Domain Driven Design - Overall pattern context