Category Archives: Software Engineering

The Ifless Principle: Designing APIs Without Hidden Decisions

Introduction

One of the most dangerous lines of code isn’t the one that throws an exception — it’s the one that hides a decision.

As engineers, we often celebrate flexible methods: a single save() that “magically” knows when to insert or update, a send() that picks the right channel, or an approveOrReject() that decides the outcome. At first, it feels convenient. But hidden behind that convenience lives complexity, ambiguity, and a growing army of if-statements.

The problem with too many ifs is not only code readability. It’s that each of the multiple scenarios your team must design, test, and maintain. What looks like “just one more condition” can easily become exponential in cost.

Over time, I’ve adopted a design approach I call the ifless principle: instead of burying decisions in code, we make them explicit in the design of the API and in the domain itself.


The Ifless Principle

The idea is simple:

  • Don’t let your service decide what the user already knows.
  • Express different operations as different methods, commands, or entities, even if they initially share behavior.
  • Move intelligence into rich domain entities (following Domain-Driven Design), so that rules live where they belong.

In short: ifless is not about eliminating ifs, but about putting decisions in the right place.

Example 1: Save vs Insert/Update

❌ If-full version:

public void save(Order order) {
    if (order.getId() == null) {
        insert(order);
    } else {
        update(order);
    }
}

✅ Ifless version:

public void insert(Order order) { ... }
public void update(Order order) { ... }

Even if both methods are identical today, the design already anticipates that inserts and updates will evolve differently. More importantly, the caller knows the intent, so the service doesn’t have to guess.

Example 2: Approvals

If hidden in the service:

public void approveOrReject(Transaction tx, boolean approve) {
    if (approve) { ... } else { ... }
}

✅ Ifless API:

public void approve(Transaction tx) { ... }
public void reject(Transaction tx) { ... }

Each operation has its own lifecycle, rules, and evolution. Tests become more focused, and the API expresses intention clearly.

Example 3: Notifications

❌ Conditional channel selection:

notificationService.send(user, message, channel);

✅ Ifless separation:

emailNotification.send(user, message);
smsNotification.send(user, message);
pushNotification.send(user, message);

Instead of one method with multiple branching conditions, each channel implements its own rules. Adding a new channel doesn’t mean touching a giant switch-case.

Connection with Domain-Driven Design

In Domain-Driven Design (DDD), the domain model encapsulates the core logic. That means invariants (like “an order can only ship if it is paid”) should live inside the entity itself:

public class Order {
    public void ship() {
        if (!this.isPaid()) {
            throw new BusinessException("Order must be paid before shipping");
        }
        // proceed with shipping...
    }
}

Notice: there’s still an if — but it’s not scattered across services. It’s encapsulated in the place where the rule truly belongs: the Order entity.

This is ifless in spirit: decisions are modeled explicitly in the domain, not left to a god-service to decide.

Benefits of the Ifless Principle

    1. Clarity of API

    The method name tells you exactly what it does. No hidden branching.

    2. Reduced Test Explosion

    Each if doubles the number of possible execution paths. Removing ifs from services simplifies test design.

    Example: save() with insert/update needs at least 2 test suites; insert and update each need only 1.

    3. Evolution without Risk

    As requirements diverge, methods evolve independently. You don’t risk breaking insert logic while changing update.

    4. Alignment with SRP (Single Responsibility Principle)

    One method = one reason to change.

    5. Cleaner Architecture

    Services stay thin. Entities stay rich. Decisions are explicit.

    Trade-offs and Counterpoints

    No principle is universal. Ifless comes with its own costs:

    • Verbosity: You might end up with more methods or services, even when differences are minimal.
    • Client Burden: Sometimes, callers just want a convenient save(). Exposing too much detail can reduce ergonomics.
    • Breaking conventions: Frameworks like Hibernate and Spring Data already assume methods like save() or merge(). Going against the grain might surprise new developers.

    That’s why I see ifless not as a dogma, but as a compass. Use it when clarity, testability, and explicit design outweigh the convenience of a single method.

    Related Ideas and References


    Conclusion

    Every if has a cost. Not just in code complexity, but in testing, maintenance, and evolution.

    The ifless principle is about making decisions explicit in the design of your API and your domain. It’s about contracts that express intent without ambiguity.

    It doesn’t mean you’ll never write an if. It means your architecture won’t hide them in the wrong places.

    In the age of scaling startups with fewer resources, clarity in design is not a luxury — it’s survival.

    Nine Women Can’t Make One Baby: Why Smaller Software Teams Deliver More

    In software engineering, scaling a project doesn’t work the same way as scaling manufacturing. While hiring more developers can increase overall capacity, it doesn’t proportionally accelerate the delivery of a single feature or project. This insight was famously captured by Fred Brooks in The Mythical Man‑Month, where he observed that “adding manpower to a late software project makes it later” . Brooks illustrated the problem with an analogy: one woman can produce a baby in nine months, but nine women working together cannot produce a baby in one month . This law isn’t about biology — it’s about the inherent constraints of complex work.

    Why throwing people at a project often backfires

    Brooks’s law identifies three fundamental reasons why adding more people to a software project can actually slow it down:

    1. Ramp‑up time. New team members need time to learn the codebase and context. Experienced developers must stop what they’re doing to train newcomers, temporarily reducing productivity . In some cases, new hires even introduce bugs while still ramping up, pushing the project further from completion .
    2. Communication overhead. Coordination paths grow exponentially as the team grows. Each person must keep others informed, creating more meetings, emails and stand‑ups . The Nuclino blog visualizes this: a three‑person team has three communication links, but adding three more members increases the links to fifteen .
    3. Limited divisibility of tasks. Not all work can be partitioned into smaller pieces. Some tasks demand sequential design and integration. Brooks points out that many software tasks are inherently indivisible . The two‑pizza‑team article expands this: you can’t simply split a complex design problem into tiny independent tickets and expect the result to emerge organically .

    These forces mean that there is an upper limit to the productivity gains you can achieve by simply adding developers. At some point, coordination costs and integration complexity outweigh the benefit of having more hands on deck.

    The case for small, focused teams

    For decades, agile practitioners have advocated small, cross‑functional teams. Jeff Bezos famously framed Amazon’s two‑pizza team rule: if a team cannot be fed with two pizzas, it is too big . The rationale is that small teams minimize communication overhead, allow rapid decision‑making, and foster accountability. Harvard psychologist J. Richard Hackman also warned that larger groups suffer from process problems and dysfunctional dynamics.

    Research backs this up. Mike Cohn cites a study in which teams were asked whether their group was too large to achieve the best result. Nearly everyone agreed that teams become inefficient above five members . Analysing over 1,000 software projects, Kate Armel found that projects delivered by teams of four or fewer developers were far more cost‑efficient and had fewer defects than those built by larger teams . The data suggests that four to five people is a sweet spot for most agile projects.

    My own “magic number”: three developers

    After years of experimenting with different team compositions working as CTO at eits.com.br, I’ve discovered a pragmatic variation on this theme: three developers can deliver remarkable results during a two‑week sprint. With trios, communication paths are minimal (three links), the team can self‑organize without excessive coordination, and everyone has a clear sense of ownership. It’s easier to maintain shared context, perform peer reviews, and collaborate closely on design decisions. If you add more people, you inevitably introduce hand‑offs and waiting, and the time spent aligning increases faster than the productive time gained.

    This isn’t just about efficiency — it’s about creativity. Complex problem‑solving often benefits from deep focus and uninterrupted thought. When more developers are involved, everyone gravitates toward smaller sub‑tasks, and the holistic view of the solution can get fragmented. A trio can tackle architecture, coding and testing collaboratively while still preserving big‑picture coherence.

    Constraints outside the team

    Adding developers doesn’t just create internal coordination issues; it also assumes that there is enough parallelizable work to keep everyone busy. In practice, business requirements, product design and stakeholder input often limit throughput. If there aren’t enough well‑defined tasks, additional engineers either wait idle or start working on poorly defined work, increasing rework later. Similarly, creativity and solution design don’t scale linearly. Some problems require brainstorming and iterative design cycles that don’t benefit from extra hands.

    Mitigating the urge to scale up

    How can leaders resist the instinct to “manpower their way” out of a schedule slip? Here are some strategies:

    • Invest early. Brooks noted that adding developers late in a project is particularly harmful . If you anticipate needing more people, bring them in early when ramp‑up costs are easier to absorb.
    • Focus on talent, not headcount. Adding one highly experienced developer may yield more benefit than hiring several junior engineers. Good programmers require less ramp‑up and introduce fewer defects .
    • Prioritize architecture and requirements. Many delays stem from unclear requirements or architectural flaws. Spend time up front clarifying what needs to be built and how pieces will fit together. This reduces integration challenges later.
    • Keep teams autonomous. When multiple small teams work in parallel, ensure their interfaces are well-defined to minimize cross-team dependencies. Jeff Bezos’ decentralization mantra and the two‑pizza rule were born from this philosophy.

    Conclusion

    The baby metaphor endures because it cuts to the core of software project dynamics: you can’t compress all tasks simply by adding more people. There is a natural limit to how much work can be parallelized; beyond that, communication overhead, ramp‑up time and cognitive load drag the project down. Research suggests that small teams — typically four to five people — are optimal , and my own experience shows that three developers often deliver the best trade‑off between speed, quality and creativity.

    Before you attempt to “scale up” your team to meet a deadline, ask whether the extra hands will actually move the delivery forward or whether they’ll simply add more complexity. Sometimes the most effective strategy is to empower a small, focused team, give them clear goals, and trust them to deliver.