Clean&Reactoring Entry Created: 04 Feb 2026 Updated: 04 Feb 2026

The Name is the Documentation: 3 Rules for Naming Functions

In modern software development, we often strive to write code that requires no comments. When you remove comments, the function name becomes the only clue to what the code does. Therefore, naming is not just a stylistic choice; it is a structural necessity.

Based on the philosophy of clean code, a good function name must satisfy three core properties: Honesty, Completeness, and Domain Understanding.

1. The Name Must Be Honest

Rule: The name must describe the function's true intention, not just its mechanism. An honest name tells the caller exactly what to expect. A dishonest name hides behavior (side effects).

  1. Bad (Dishonest):
public void GetUser()
{
// This is dishonest because "Get" implies a simple retrieval,
// but it actually modifies the database!
var user = db.Users.Find(1);
user.LastLogin = DateTime.Now; // Side effect!
db.SaveChanges();
}
  1. Good (Honest):
public void GetUserAndRefreshLoginSession()
{
// The name warns the developer that a change will occur.
}

2. The Name Must Be Complete

Rule: The name must capture everything the function does. If a function performs two distinct actions, the name must reflect both (or the function should be split). Avoiding long names is not an excuse for incomplete names.

  1. Bad (Incomplete):
public void ProcessOrder(Order order)
{
ValidateStock(order);
ShipItems(order);
SendEmail(order); // The name "Process" hides the fact that an email is sent.
}
  1. Good (Complete):
public void FulfillOrderAndNotifyCustomer(Order order)
{
// Now the caller knows that an email notification is part of the deal.
}

3. The Name Must Be Understandable (Domain Language)

Rule: Use words from the business domain, not computer science jargon. This concept (often called Ubiquitous Language in Domain-Driven Design) ensures that developers and business experts speak the same language. Avoid technical terms like "List", "Array", or "Flag" if a business term exists.

  1. Bad (Technical Jargon):
public void RemoveItemFromList(int index)
{
// "List" is a technical term, not a business term.
}
  1. Good (Domain Language):
public void VoidLineItem(int lineItemId)
{
// "Void" and "Line Item" are terms the business actually uses.
}
Share this lesson: