BEES Functional Trainings · Engineering & Platform · Workshop 1 · Classes 1 and 2

Software Engineering & Programming Tools · 2 hours · online

Designing for Managed Variability

The session compares the mechanisms that let one platform accommodate differences across customers and markets without spreading conditionals through the code, multiplying special operations or raising the risk to critical services. The lab applies them to three needs of Tradeline, a fictional B2B marketplace.

Planned variabilityMulti-tenancyFlags and entitlementsPlatform primitivesAI for large-scale changes
Session objective and structure

Guiding question: how can we accommodate differences across customers and markets without scattering variation throughout the code, without multiplying special operations and without increasing risk to the critical services of the ecosystem?

0Opening and retrieval poll10 min
10Concept briefing30 min
40Worked example15 min
55Break and groups5 min
60Architecture Option Lab40 min
100Debrief15 min
115Transfer5 min
By the end of the session

Participants classify variations by type and binding time, compare mechanisms by coupling, testability, isolation, cost and blast radius, encapsulate tenant and market context in platform primitives and use AI agents for impact analysis under architectural constraints.

Artifact

Architecture Option Sketch: for each of the three lab needs, two options with explicit testing and operating costs and the effect of a failure on the end user and on the critical services.

Retrieval from the Kick Off: options for a new demand

Every demand that reaches the platform ends in one of seven options. This session deals with the technical mechanisms behind the options that keep the demand inside the product.

OptionWhen it tends to be appropriate
RejectLow strategic fit, or cost and complexity that cannot be justified
Defer and learnEvidence is insufficient and uncertainty must be reduced before deciding
Use existing capabilityThe need is met by discovery, enablement or process, without a new feature
Configure or entitleAnticipated variation, or an offering differentiated by segment or tier
Generalize into coreA recurring need that justifies a global abstraction
Extend or integrateA valid need that is better met outside the core, through API, adapter, event or plugin
Bespoke exceptionLast resort, with sponsor, total cost, lifecycle, observability and an exit plan
Poll: which variation mechanism is most used in your systems today? Country or customer conditionals, configuration files, metadata tables, feature flags, entitlements, extension points and adapters, or separate deployments per customer or region.
Planned variability: core, variation points and variants

Software product line engineering separates what is common to every customer from what is allowed to differ, and decides in advance where and when each difference is resolved.

Common core

Shared by all customers and markets

Capabilities and rules that remain consistent everywhere and evolve as part of the common product. At Tradeline, order issuing, the order state machine and the pricing pipeline belong to the core.

Variation point

A declared place where behaviour may differ

A point in the architecture where the product admits alternatives, such as the tax applied to an order. The variation point is designed once and has a known contract.

Variant

One alternative bound to a variation point

The concrete behaviour selected for a market, a tier or a customer, such as IVA at 19% in Colombia. Variants are added without changing the code of the core.

Binding time

When the variant is chosen

At build, at deploy or at runtime. Later binding gives flexibility per tenant and moves cost to testing and operations, because more combinations exist in production.

Pohl, Böckle & van der Linden (2005); Apel et al. (2013)

Five types of variation and their binding time

Classifying a demand before choosing a mechanism avoids treating every difference in the same way. The type indicates who owns the rule and how long it is expected to last.

TypeWhat variesExample at TradelineTypical binding
DomainHow the business works in a segment or service modelIndirect model: the distributor, and not the manufacturer, confirms stockRuntime, per tenant
CommercialWhat a customer bought or negotiatedPremium distributors get approval workflowsRuntime, per entitlement
RegulatoryWhat the law of a market requiresTax rules, fiscal identifiers, electronic invoicesRuntime, per market, with legal start date
ReleaseWhether a new behaviour is exposed yetNew checkout shown to 5% of retailersRuntime, temporary
InfrastructureWhere and how the software runsData residency for one market, dedicated capacityDeploy
A single demand can combine types. The approval flow requested by premium distributors is commercial in origin and becomes a domain variation once the thresholds differ by region.
Seven mechanisms compared

No mechanism is better in general. Each one moves the cost of variation to a different place, and the choice depends on the type of variation and on how much the variants must be isolated from each other.

MechanismCouplingTestabilityIsolationCostBlast radius
ConfigurationLow, if the parameter is anticipatedGood per value; combinations growNone between tenantsLow to buildWrong value affects the tenant or market
MetadataLow; behaviour described as dataNeeds tests of the interpreter and of the dataLogicalHigh upfront, low per variantAn interpreter bug reaches everyone
EntitlementLow; checks a contractGood; finite set of plansLogicalModerate; needs a billing linkLimited to the plan
Feature flagGrows with every flag left in the codeDoubles paths per flagNoneLow now, debt laterSmall if the cohort is small
Extension pointDefined by the contractContract tests per extensionDepends on where the extension runsModerateContained if extensions are sandboxed
AdapterConfined to the integration edgeContract tests against each partnerGood at the edgeOne per partner or protocolThe integrated partner
Deployment stampNone in codeSame code, more environmentsPhysicalHighest to operateOne stamp
Multi-tenant models: pool, silo and bridge

The tenancy model decides how much of the infrastructure customers share. It determines the cost to serve, the isolation of failures and the noise one tenant can cause to the others.

Pool

Everything shared

All tenants run on the same services and databases, separated by a tenant identifier. Lowest cost to serve and simplest to evolve, with the risk of noisy neighbours and a blast radius that covers everyone.

Silo

Dedicated resources

Each tenant, or each market, gets its own stack. Strong isolation and easy compliance with residency rules, with higher operating cost and the temptation to let each silo diverge in code.

Bridge

Mixed by layer or tier

Some layers are pooled and others are siloed, for example a shared application tier with a dedicated database for a large distributor. Most real platforms end up here.

Whatever the model, the code needs a tenant context: who the tenant is, its market, tier and entitlements, propagated with every request and every event. Metadata-driven platforms resolve behaviour from that context instead of branching on it.

Golding (2024); Microsoft (2024); Weissman & Bobrowski (2009)

Feature flags and entitlements have different lifecycles

A toggle is classified by why it exists and how long it should live. Using release flags as permanent commercial differentiation is the most common confusion in this topic.

TogglePurposeExpected lifeWho changes it
ReleaseShip incomplete code safely and expose it progressivelyDays to weeks, then removedEngineering
ExperimentCompare variants for a decisionDuration of the experimentProduct and data
OperationsDegrade or switch off a feature under load or failureLong-lived, rarely changedSRE and on-call
PermissionGive access to a capability for some usersLong-livedProduct and support
EntitlementExpress what a customer bought or negotiatedAs long as the contractCommercial, through billing
Each flag needs an owner, a removal date and a test of both paths. An entitlement needs a link to the contract and a single place in the code where it is checked.

Hodgson (2017)

Platform primitives instead of conditionals

A platform team offers a library or service that resolves tenant and market context once. Application code asks the primitive for a policy and no longer knows which country it is serving.

Before · service/orders/pricing.py
def compute_tax(order):
    if order.country == "BR":
        tax = order.subtotal * 0.18
    elif order.country == "MX":
        tax = order.subtotal * 0.16
    elif order.country == "CO":
        tax = order.subtotal * 0.19
    ...
    if order.country == "BR" and \
       order.customer.customer_id == "DIST-0042":
        st = order.subtotal * override
After · policy resolved from context
def compute_tax(order, ctx: TenantContext):
    policy = tax_policies.resolve(
        market=ctx.market,
        delivery_region=order.delivery_region,
        tier=ctx.tier,
        at=order.issued_at,
    )
    return policy.apply(order)

# policies are versioned data with an owner,
# a start date and tests per policy
Golden paths make the primitive the easiest way to build. A new market then becomes a new policy reviewed by the owner of the rule, and not a new branch in every layer.

Fournier & Nowland (2024); Skelton & Pais (2019)

AI agents for large-scale changes

Coding agents speed up the search for every occurrence of a variation and the first draft of the refactoring. The speed is only useful when the output is verified against the repository and the architecture.

1Search

Ask the agent to find every place where the market decides behaviour, in all layers, including SQL and configuration.

2Impact map

Require file, line and reason for each occurrence, and the list of what was searched.

3Verify

Confirm each line by hand, look for spellings the agent did not try and remove false positives.

4Constrain

State the architecture rules in the prompt: public contracts that cannot change, where the primitive lives.

5Review

Review the diff as code from a new colleague: tests of both paths, no secrets, no unsafe input handling.

Generated code inherits the security risks of any code, and some of its own, such as invented dependencies and credentials copied from context. Human review and the usual pipeline checks remain mandatory.

DORA (2025); OWASP (2024)

Worked example: a real case and a live demo

The facilitator first presents a case from BEES engineering, then repeats the reasoning on the Tradeline sample repository with a coding agent.

Part 1 · BEES engineering case

Constraints before the solution

Presented live. Observe three things: which API contracts could not change because of the systems integrated with them, how latency in one service cascades to the user, and how far a failure in catalog and pricing would reach. Then observe why the chosen change stayed close to the user layer.

Part 2 · Live demo in Cursor

From conditionals to a policy

On tradeline-orders-sample, the agent maps every country conditional of the tax rule in the UI, the service and SQL. The facilitator checks the map against the repository, shows what it missed, and asks for the extraction into a configurable policy under stated constraints.

While watching, note one decision the facilitator made because of a constraint, and not because of preference. It is the question the lab asks of each group.
Lab: three needs at Tradeline

Tradeline is a fictional global B2B ordering marketplace operating in Brazil, Mexico, Colombia, South Africa and the Dominican Republic. Its tax rule already lives as country conditionals in three layers.

Need 1 · Regulatory

Regional tax rule at order issuing

Colombia exempts orders delivered to two departments from IVA, from a legal start date. Mexico may follow with border zones. The rule depends on the delivery address.

Need 2 · Commercial

Approval flow for premium distributors

About 120 premium accounts want orders above their own threshold to wait for a purchasing manager. Some want thresholds per region, one wants two approvers.

Need 3 · Integration

ERP of a large distributor

The largest distributor in South Africa wants orders pushed in real time and stock pulled every 15 minutes from a SOAP ERP that changes twice a year. Others may ask next.

The full brief, the sample repository and the template are in the lab kit: needs-brief.md, tradeline-orders-sample.zip and architecture-option-sketch-template.md.
Lab steps and roles

Groups of five or six in breakout rooms, 40 minutes. Roles rotate every workshop.

5′Classify

Type of variation and binding time of each need.

15′Two options per need

Effects on code, deployment, testing, operations and cost, and the missing information.

10′Agent impact map

Map every occurrence of the tax conditional and propose the extraction into a policy. Verify the map by hand.

5′Failure effects

For the preferred option, what happens to the retailer and to critical services if it fails.

5′Close the sketch

Check that every need has two options with explicit testing and operating costs.

Lead

Conducts the discussion and keeps the group on the three needs.

Recorder

Writes the Architecture Option Sketch in the template.

Timekeeper

Announces each step and protects the last five minutes.

Skeptic

Challenges assumptions and asks what the option costs to test and operate.

Architecture Option Sketch

One block per need. Write ranges or "unknown" when the group does not know, and record what it would need to find out.

FieldOption AOption B
Type of variation and binding timeDomain, commercial, regulatory, release or infrastructure; build, deploy or runtime, and why
Mechanism and where it is encapsulated……
Effect on code and deployment……
Testing cost……
Operating cost, isolation and blast radius……
Missing informationWhat the group would ask before deciding
Preferred option and failure effectEffect on the retailer and on order issuing, catalog and pricing if it fails
What would change our mindThe fact that would reverse the provisional direction
Differentiation by class and no-login alternative

Both classes run the same lab. The emphasis changes with the profile of the participants.

Class 1 · Developers

Refactoring and the primitive

More time for the assisted refactoring: the group implements the tax policy primitive in the sample repository and keeps the existing tests passing.

Class 2 · Architects, QA, SRE

Mechanisms and isolation

Architects lead the comparison of mechanisms and tenancy models; QA and SRE assess the testability and operability of each option.

No-login alternative

Pre-generated agent output

If Cursor or the repository is not accessible, the group verifies impact-map-pregenerated.md against the code listings in the kit.

Mixed groups work well in both classes. In Class 1, a developer drives the agent while the skeptic checks each occurrence in the code; in Class 2, the QA or SRE participant writes the testing and operating cost lines of the sketch, which are the lines groups most often leave empty.
Assistant facilitators circulate through the breakout rooms. When a group stalls on need 3, they ask which part of the integration belongs to the core contract and which part belongs only to this distributor.
Debrief: comparing the chosen options

Fifteen minutes across groups. The comparison matters more than any single answer.

Questions

Which groups chose the same mechanism for the same need, and did they justify it by the same constraint? What is the testing cost of the preferred option for need 1, measured in combinations of market, region and date? Which occurrences did the agent miss, and why was the search unable to find them? Where did a group use a feature flag for something that will last as long as a contract?

Transferable principles

Classify the variation before choosing the mechanism. Resolve tenant and market context in one place. Give every exception an owner, a cost and an exit path. Treat an impact map produced by an agent as a hypothesis to verify.

5′Need 1 across groups

Two groups present their options for the regional tax rule; the others mark agreement and disagreement.

5′The agent map

Groups compare the occurrences they confirmed, removed and added to the agent's impact map.

5′Needs 2 and 3

One flag-versus-entitlement decision and one adapter decision, with their testing costs.

Formative rubric

There is no grade. The rubric tells each group where its sketch stands and what to strengthen in the post-work.

CriterionProficientDeveloping
ClassificationType and binding time of each variation correctly identifiedAll variations treated as the same
Mechanism comparisonOptions evaluated by coupling, testing, operations, cost and effect on critical services and end usersA single solution chosen by preference
Use of AIImpact map verified and extraction consistent with the architectureAgent output accepted without verification
How the rubric is used

Each group reads its own sketch against the three criteria during the debrief and marks one criterion where it is still developing. That criterion becomes the focus of the post-work.

Evidence the facilitator looks for

A classification for each need, two options with the testing and operating cost written down, and an impact map with at least one occurrence confirmed, added or removed by hand.

Post-work and bridge to Workshop 2

The post-work applies the sketch to a real variation of the participant's own system, without confidential names.

Post-work · 20 minutes

Architecture Option Sketch for a real variation

Demand type, options, trade-offs, provisional direction and what would change your mind. Bring it to Project Development.

Next · Workshop 2

Code Review and Operational Excellence: Preventing Variant Debt

The next session starts from what happens when the options of today are not followed: conditionals in every layer, columns created for one customer and flags that never leave the code.

Reading material, lab kit and references are in the material of this session. Tradeline is a fictional company and all its data is synthetic.

About this session

Designing for Managed Variability · Prof. Afonso

Learning objective

By the end of the session, participants should be able to classify variations across customers and markets by type and binding time, compare configuration, metadata, entitlement, feature flag, extension point, adapter and deployment stamp by coupling, testability, isolation, cost and blast radius, propose the encapsulation of tenant and market context in platform primitives, and verify an impact map produced by an AI coding agent before accepting a refactoring.

Session strategy

Two-hour online workshop following the standard structure of the program. A retrieval poll on the decision options of the Kick Off opens the session, a thirty-minute briefing presents planned variability, multi-tenancy, flags and entitlements, platform primitives and AI for large-scale changes, and the facilitator works through a real case from BEES engineering and a live demo in Cursor on the sample repository of Tradeline, a fictional B2B marketplace. Groups of five or six with rotating roles then write an Architecture Option Sketch for three needs and verify the agent's impact map, followed by a debrief across groups and the post-work.

Session structure

  1. Opening and retrieval poll — 10 min
  2. Concept briefing: planned variability, types of variation, mechanisms, multi-tenancy, flags and entitlements, platform primitives and AI — 30 min
  3. Worked example: BEES engineering case and live demo in Cursor — 15 min
  4. Break and group formation — 5 min
  5. Architecture Option Lab on three Tradeline needs — 40 min
  6. Debrief across groups — 15 min
  7. Transfer: post-work and bridge to Workshop 2 — 5 min