Skip to content

Lesson 12 of 17 · How We Think About Code

Naming Things by Intent

Intermediate•
lesson•
September 10, 2026•
~9 min read

Two famously hard things

Phil Karlton's quote has been recycled so many times that it's become a meme:

There are only two hard things in Computer Science: cache invalidation and naming things.

Plenty of teams still treat naming as the part of code review where someone bikesheds about variable names.

If you've sat through enough team arguments about a piece of code, you start to notice that most of them aren't really about the code. They're about what the code should be called, in disguise. The function does what it does; the disagreement is whether what it does deserves the name in front of it.

Names are the densest piece of design work in a codebase. Every name commits the team to a story about what something is for. Get the story right and the code reads like sentences. Get it wrong and you spend the rest of the project arguing with your past self.

Mechanical names vs intent names

A mechanical name describes how the thing works. BookingService, DataHandler, ProcessCsv, ReservationProcessor. The reader, looking at the name, learns something about the implementation. They don't learn anything about why the thing exists.

An intent name describes what the thing is for. Reservation::confirm(), Reservation::cancel(), GuestCheckedIn, RatePlan. The reader learns the purpose first. The implementation comes later, in the body, where it belongs.

The asymmetry between the two is what makes intent names so valuable. Mechanical names date the moment the implementation changes. The day you rewrite ReservationProcessor to use a queue instead of a synchronous flow, the name is a small lie. Intent names survive that change. Reservation::confirm() is still about confirming a reservation whether it happens in-process, in a job, in three steps, or one.

The tells of mechanical naming

Mechanical names give themselves away pretty consistently:

  • Generic suffixes. Manager, Helper, Util, Service, Processor, Handler (when the rest of the name doesn't already commit to anything specific). The suffix is doing the entire job of the name, and the suffix says nothing.

  • Code verbs, not domain verbs. process, handle, execute, do, run. These verbs describe what the code does, not what the business does.

  • Type-as-name. BookingService, ReservationService, GuestService. The class name is the noun plus a generic suffix. There's no commitment to what specifically this service does with bookings, reservations, or guests. Service classes named this way tend to end up doing too many things, because the name didn't ask them not to.

  • Generic data words. Data, Info, Object, Item, Entry. ReservationData is a worse name than Reservation. GuestInfo is a worse name than Guest. The suffix dilutes the noun without adding anything.

  • Abstract patterns as names. ReservationFactoryBuilder, PaymentDispatcher, GuestCoordinator. The name describes the pattern instead of the role. The reader has to know the pattern to know what the class is for.

If a class name could be reused, unchanged, in three completely different products, that's a strong sign the name is mechanical. The name should fit one specific business.

The tells of intent naming

Intent names look different:

  • The name appears in conversations with non-developers without translation. A product manager says "we need to confirm the reservation". The class has a method called Reservation::confirm(). There's no translation step.

  • The name implies a verb without needing the verb spelled out. Refund, RatePlan, Cancellation. The reader knows what's happening from the noun alone.

  • The name commits to a specific business meaning. CancellationPolicy is more specific than PolicyHandler. ReservationConfirmation is more specific than ReservationManager.

  • You could read the name to a domain expert and they'd nod. That's the strongest test. If they'd ask "what does that mean?", the name is mechanical.

You can usually rename mechanical to intent in one move, once you decide to look. The harder part is noticing the mechanical name was bothering you in the first place.

A worked example

Imagine a class that grew a method every time nobody knew where the new thing should live:

PHP
<?php declare(strict_types=1); namespace App\Reservations; final class BookingService { public function do(int $reservationId): void { /* ... */ } public function cancelBooking(int $reservationId, string $reason): void { /* ... */ } public function updateBookingStatus(int $reservationId, string $status): void { /* ... */ } public function getBookingsByCustomer(int $customerId): array { /* ... */ } public function validateBooking(array $input): bool { /* ... */ } }

BookingService does five things. The name doesn't commit to any of them, which is exactly why all five ended up in the same class. And do() is the worst name on the worst class: the reader cannot tell whether it requests, confirms, checks in, or charges, without opening the body.

If you split by intent, the seams that were already there name themselves:

  • do is really "confirm this reservation". → Reservation::confirm().

  • cancelBooking is really "cancel this reservation". → Reservation::cancel() and a CancelReservation use case.

  • updateBookingStatus is really transitioning the reservation between states. → methods on the reservation itself: Reservation::checkIn() and Reservation::checkOut(), next to the confirm() and cancel() above.

  • getBookingsByCustomer is really "what stays this guest has had". → GuestStayHistory.

  • validateBooking is really enforcing rules about whether a reservation is allowed. → invariants on Room itself, which is where Room::reserve() already checks availability.

Five intent-named pieces, each with a real concept behind it. The "fat service" is gone, and so is the constant question "where should this new thing live?". The new question has an answer, because the seams are named. Notice also that the word "booking" disappeared on the way in: the business calls these "reservations", and the code now does too.

Naming is design, not decoration

When the name is wrong, the design is usually wrong too. A class called Manager exists because nobody decided what it actually is. A method called process exists because nobody decided what it actually does. The mechanical name is a placeholder that never got replaced, and the placeholder shapes everything that lands on top of it.

A useful rule that cuts through a lot of these problems:

If you can't name it cleanly, you haven't designed it yet.

The corollary: write the name first. Before the function body. Before the class structure or the database schema. The name is the smallest, cheapest representation of the design. If it comes out as ReservationProcessor, stop. Either you're not yet sure what you're building, or you're trying to build two things in one. Both are good things to know before writing code, and bad things to discover once other code already depends on the wrong shape.

This is the same idea that came up with writing the name first and with the business-process mindset. Naming is the place where those two meet. If you're naming by intent, you're already thinking in business processes, and you're already writing for the reader.

Names age, and that's okay

Some names will be wrong later, even when they were right at the time. The business calls something a "subscription" until the day it decides it's actually a "membership". A workflow that was "approval" is renamed "review" because the legal team prefers a softer word. The name in the code now lags reality.

The fix is renaming, and the healthiest codebases I've worked in have rename PRs in their history, often. They're small, mechanical, and almost always landed in their own commit. They keep the language of the code and the language of the business in sync, which keeps the code readable for the people who write it and the people who specify it.

The unhealthy version is when the codebase keeps the old name forever, "because everyone knows what it really means". Everyone except the new hire, every external auditor, every customer support person trying to read the code, and every engineer who joins after the cohort that remembers has moved on.

Match the business's vocabulary

If the team calls it "confirming a reservation", the code uses Reservation::confirm() and a ConfirmReservation use case. Not BookingProcessingService. The name the business uses is the right name for the code, and any rewording is friction someone is paying for, every time they have to map between the two vocabularies.

The cost of a parallel vocabulary is hidden, because nobody bills you for it. It's paid in every meeting where the engineer says "you mean processing the reservation?" and the product person says "no, confirming it", and they stop to synchronize what they both already understood.

Use the business's words. Even when they're slightly awkward in code. The awkwardness is information; it usually means there's a domain concept that doesn't have a standard programming label. That's exactly the kind of name worth keeping.

A few practical naming choices

Some of the small recurring questions, with opinions:

  • Collections. Name a repository or store after the plural of the thing, not after a generic suffix. Reservations, not ReservationRepository. The interface tells you what it deals with; the implementation can pick a longer name (EloquentReservations).

  • Single things. Reservation. Guest. Room. The simplest noun the business uses for the thing.

  • Ports for third parties. Name them for what they do in your domain, not for the vendor. Mailer, not SendgridClient. Payments, not StripeService. The vendor is an implementation detail and shouldn't be in the name of the seam.

  • Interfaces. Don't prefix with I. The interface is the thing. The implementation gets a longer, more specific name. Mailer is the interface; SendgridMailer is one implementation.

  • Events. Past tense, plain English: ReservationConfirmed, GuestCheckedIn, PaymentCaptured. The event is something that already happened.

  • Use cases / commands. Imperative verb plus subject for the use case: ConfirmReservation, CancelReservation, RefundPayment. They describe an action being requested. Inside the use case, the command and its handler take the suffix: ConfirmReservationCommand, ConfirmReservationCommandHandler.

Most of these are conventions you can pick once and apply consistently. The convention matters less than the consistency. The reader's job gets harder every time the same kind of thing has two different naming styles in the codebase.

"Can the name be shorter?"

A small trick that pays off often: once you have a name, ask whether you can write it using only words from the domain. If yes, you've got it. If you keep needing technical words to disambiguate (Service, Handler, Manager, Processor), the design is leaking technicalities into the name.

Sometimes you do need a technical word. ReservationQuery, ReservationCommand, ReservationEvent are technical, and they're fine, because they describe a kind of thing in your application's structure. The trick is that the technical word is doing useful work there, distinguishing roles. The bad cases are where the technical word is the only word doing any work, like in BookingService.

If you remove the technical word and the name still tells the reader what the thing is for, the technical word was noise. If you remove it and the name stops making sense, it was earning its keep.

What this isn't

ReservationConfirmationCommandExecutionDispatchHandler is a mechanical name with five suffixes stapled on, no matter how long it runs. Intent means the words in the name describe what the thing is for, with no padding - length was never the point. WhenAGuestConfirmsAReservationAndAcceptsTheCancellationPolicy reads like a docstring with no spaces. None of this is a license to spend an afternoon renaming everything in the codebase the day you read this. Pick the one or two worst names in the file you're already in, fix those, and move on. Keep doing that and it beats any one-shot renaming sprint.

The one thing to remember

Mechanical names tell the reader how the code works today, and that description goes stale the moment the implementation changes. Intent names tell the reader why the code exists at all, and that doesn't. If you only invest in one habit from this whole course, invest in this one. Almost everything else gets cheaper when the names in your codebase tell the truth.

Course Content