As developers, we live in a world of functions. createUser(), sendInvoice(), updateStatus(). We write them, call them, and chain them together to build our applications. They are the fundamental building blocks of software. But what if this function-centric view is holding us back?
A simple function call is just an execution instruction. It lacks inherent business context, consistent logging, and a built-in audit trail. A single business process, like a user signing up, might trigger a cascade of disparate functions across multiple services, with its true meaning scattered and lost in the implementation details.
This is where a paradigm shift is needed. We need to move beyond simple functions and start thinking in terms of Verbs: clear, structured, and observable business actions. This is the core principle behind Verbs.do—treating your business operations as "Actions as Code."
When your business logic is only expressed as a collection of functions, you inevitably run into several challenges:
A Verb, in the context of Verbs.do, is not just a function. It's a standardized, formal definition of a business action. It encapsulates the what, who, why, and what happens next into a single, reusable unit.
Let's look at a simple, powerful example. Instead of just calling a function, you first define the action itself.
import { Verb } from 'verbs.do';
// Define a 'SignUp' action once
const signUp = new Verb({
name: 'SignUp',
description: 'A new user creates an account.',
subject: { type: 'User' },
properties: {
email: { type: 'string', format: 'email' },
password: { type: 'string', sensitive: true }
},
effects: [
{ name: 'CreateUserRecord' },
{ name: 'SendWelcomeEmail' }
]
});
This definition establishes a crystal-clear contract for a core business process. It declares the actor (subject), the data required (properties), and even the intended side-effects (effects) like creating a database record or sending an email. This is your single source of truth for what a "SignUp" is.
Once defined, this Verb can be executed from anywhere in your application stack with a simple API call.
// Execute it anywhere in your application
await signUp.execute({
subject: { id: 'user_123' },
properties: {
email: 'hello@example.com',
password: 'a-secure-password'
}
});
This is where the magic happens. This single execute call does more than just run code. It triggers a series of powerful, automated benefits that are nearly impossible to achieve consistently with standard function calls.
Adopting a Verb-centric approach fundamentally changes how you build and reason about your systems.
Every time a Verb is executed, Verbs.do creates a detailed, immutable log. This event record contains:
Suddenly, you have a comprehensive audit trail and event stream of every significant action in your business. Answering "Who did what, and when?" goes from a week-long investigation to a simple query. This is a game-changer for compliance, security, and debugging.
Remember the effects array in our definition? That's your workflow automation blueprint. It explicitly states that a SignUp Verb should trigger CreateUserRecord and SendWelcomeEmail. The orchestration logic is co-located with the action's definition, not hidden in imperative code. This makes your business processes explicit, understandable, and easier to modify.
Your code begins to speak the language of your business. Instead of developers trying to interpret what u_create_v2(p1, p2) does, they see SignUp.execute(). This approach, which we call Business-as-Code, creates a system where the operational intent is clear, observable, and directly tied to the code that implements it.
Think of it this way:
The Verb provides the structure, context, and observability that a simple function call lacks.
By elevating your actions from simple function calls to first-class Verbs, you're not just writing code—you're building a robust, auditable, and scalable system of record for everything that happens in your business.
Ready to turn your operations into code? Explore the Verbs.do API and see how you can define, execute, and log your business actions with unprecedented clarity.