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

Designing for Managed Variability

Reading material for the first workshop of the Engineering & Platform track. It covers the pre-work, the concepts of the briefing with their sources, the lab on Tradeline, a fictional B2B marketplace, the lab kit, the template of the Architecture Option Sketch, the formative rubric and the post-work.

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

1. How to use this material

This material accompanies a two-hour online workshop for Classes 1 and 2 of the Engineering & Platform track. The session follows the standard structure of the program: an opening with a retrieval question, a thirty-minute concept briefing, a worked example, a forty-minute lab in groups, a debrief and the transfer to the next session.

Section 2 is the pre-work, which takes about fifteen minutes and should be done in the week before the session. Sections 3 to 10 develop the concepts of the briefing in more depth than the slides allow, so that the lab can be spent on decisions rather than on vocabulary. Sections 11 to 14 describe the lab, the files used in it, the template of the deliverable and the rubric, and Section 15 describes the post-work.

The lab uses Tradeline, a fictional global B2B ordering marketplace created for teaching. Tradeline connects manufacturers, distributors and retailers in Brazil, Mexico, Colombia, South Africa and the Dominican Republic. Its code, customers, rates and volumes are synthetic. The real case from BEES engineering used in the worked example is presented live by the facilitator and is not reproduced here.

Before the session

Validate your access to Cursor and to the sample repository in the Azure environment indicated by the program team. If access is not possible, the lab has a no-login alternative described in Section 12.

2. Pre-work

The pre-work takes fifteen minutes and has three parts: a short reading, a check of the environment and the identification of a form of variation in a system you know.

2.1 Reading: pool, silo and bridge

A multi-tenant platform serves many customers with one product, and the first architectural decision is how much infrastructure those customers share. In the pool model, every tenant runs on the same services and the same databases, and the data of each tenant is separated by an identifier carried in every row and every request. The model has the lowest cost to serve and lets the whole base receive a change at once, which is the reason most SaaS platforms start with it. Its cost appears when one tenant consumes more than its share, because the others feel the effect, and when a defect is deployed, because it reaches every tenant at the same time.

In the silo model, each tenant, or each group of tenants such as a market, receives dedicated resources. Isolation is physical, a failure stays inside the silo, and residency or compliance requirements are easier to meet. The price is operational: each silo must be provisioned, observed, patched and upgraded, and over time the silos tend to diverge in version and configuration unless the same pipeline deploys all of them.

The bridge model combines the two by layer or by tier. A platform may pool its application services while giving a large customer a dedicated database, or may run a premium tier in its own deployment while the standard tier stays pooled. Most platforms that serve customers of very different sizes end up in some form of bridge, and the design question becomes which layers to isolate for which tenants (Golding, 2024; Microsoft, 2024).

2.2 Reading: feature flag and entitlement

A feature flag and an entitlement can be implemented with the same if statement, and this similarity is the origin of a frequent confusion. A feature flag exists to control the exposure of a behaviour during a period: to release incomplete code safely, to compare variants in an experiment, or to switch a feature off during an incident. Its natural lifecycle ends with its removal from the code. An entitlement expresses what a customer bought or negotiated, such as access to an approval workflow included in a premium tier. It lasts as long as the contract, it is changed by the commercial process, and it should be checked in a single place connected to the record of the contract (Hodgson, 2017).

When a release flag is reused to differentiate customers commercially, the flag stops being temporary, nobody owns its removal, and the code keeps both paths indefinitely. Workshop 2 treats this accumulation as variant debt.

2.3 Tasks

  • Read Sections 2.1 and 2.2 (about eight minutes).
  • Open Cursor and the sample repository in the environment indicated by the program team, or download tradeline-orders-sample.zip and confirm that it opens.
  • Write down one form of variation already present in a system you know, such as a country conditional, a customer-specific column, a long-lived flag or a separate deployment for one customer, and note who owns it.

3. Variation at the scale of a global platform

A global B2B platform grows by adding markets, segments, verticals and partners, and each addition brings different rules, flows, integrations and commercial conditions. Meeting each demand in isolation expands reach in the short term and tends to multiply code, configurations, tests, special operations and maintenance cost. The question of the Engineering & Platform track is how to design and evolve a platform that accommodates this variation with reuse, isolation and operability, with a clear view of the risk each change poses to the business and to the people who use the product.

The program uses a shared vocabulary across its four tracks. The terms below appear throughout this session.

TermDefinition used in the sessions
Global coreCapabilities and rules that remain consistent for all customers and markets and evolve as part of the common product
ConfigurationAnticipated variation, activated by parameters, policies, tiers or metadata, without per-customer code changes
EntitlementCommercial or contractual rule defining who can use a given capability; not to be confused with a feature flag
Extension and integrationMechanisms that meet additional needs outside the core, such as APIs, adapters, events or plugins
ExceptionLogic or artifact specific to a customer or market, justifiable when it has explicit cost, owner, lifecycle and exit path
Feature flagMechanism for release, experimentation and progressive rollout, which should not become permanent product policy without governance
Variability debtAccumulated cost of branches, conditionals, forks, configurations, versions, schema differences and exceptions that are hard to test and operate
Cost-to-serveMarginal and recurring cost of operating, supporting, observing and evolving a customer, segment or capability, including the cost of incidents

4. Planned variability and binding time

Software product line engineering offers the oldest systematic treatment of the problem. Its starting point is the separation between what is common to every product of a family and what is allowed to differ. The common part forms the core, and each place where the architecture admits alternatives is a variation point. A variant is one alternative bound to a variation point, and the set of variation points with their admissible variants is the variability model of the platform (Pohl, Böckle & van der Linden, 2005).

The value of the separation lies in deciding in advance where a difference may appear. When the variation point for tax is declared, with a known contract, a new market is a new variant of that point. When it is not declared, the new market becomes a new branch wherever the code happened to need the tax, and the number of places to change grows with every market.

The second concept is binding time, the moment at which a variant is selected. Variants can be bound when the software is built, when it is deployed or while it runs (Apel et al., 2013). Earlier binding produces fewer combinations in each running system and simplifies testing, while later binding allows a single deployment to serve tenants with different behaviour. A multi-tenant platform needs runtime binding for most customer and market differences, and the consequence is that the combinations of variants coexist in production and must be tested and observed there.

5. Five types of variation

Before a mechanism is chosen, the demand should be classified, because the type of variation indicates who owns the rule, how often it changes and how long it is expected to last. The session uses five types.

TypeWhat variesExample at TradelineTypical binding
DomainHow the business works in a segment or service modelIn the indirect model, the distributor confirms stockRuntime, per tenant
CommercialWhat a customer bought or negotiatedPremium distributors receive approval workflowsRuntime, per entitlement
RegulatoryWhat the law of a market requiresTax rules, fiscal identifiers, electronic invoicesRuntime, per market and with a legal start date
ReleaseWhether a new behaviour is exposed yetA new checkout shown to a small share of retailersRuntime and temporary
InfrastructureWhere and how the software runsData residency for one market, dedicated capacityDeploy

The types are not exclusive. A demand that starts as commercial, such as an approval flow sold in a premium tier, acquires a domain dimension when each distributor wants different thresholds per region. Regulatory variation deserves attention of its own, because it carries a legal start date and, frequently, a dependency on the delivery address rather than on the customer, which places the variation point in a different part of the model.

6. Seven mechanisms compared

Seven mechanisms cover most of the ways a platform accommodates variation. None is better in general: each one moves the cost of variation to a different place, whether to the design of the core, to testing, to operations or to the integration edge. The comparison below uses the five criteria of the lab.

MechanismCouplingTestabilityIsolationCostBlast radius
ConfigurationLow, when the parameter was anticipatedGood per value; combinations grow with the number of parametersNone between tenantsLow to buildA wrong value affects the tenant or market that uses it
MetadataLow; behaviour is described as data and interpreted by the platformRequires tests of the interpreter and of each piece of metadataLogicalHigh upfront, low per new variantA defect in the interpreter reaches everyone
EntitlementLow; the code checks a contractGood, since plans are a finite setLogicalModerate; requires a link with billingLimited to the plan
Feature flagGrows with every flag that stays in the codeEach flag doubles the paths to testNoneLow now, debt laterSmall while the cohort is small
Extension pointDefined by the contract of the extensionContract tests for each extensionDepends on where the extension runsModerateContained when extensions are isolated
AdapterConfined to the integration edgeContract tests against each partnerGood at the edgeOne adapter per partner or protocolThe integrated partner
Deployment stampNone in the codeSame code, more environments to verifyPhysicalHighest to operateOne stamp

Two observations guide the use of the table. The first is that the criteria trade against each other: the deployment stamp isolates best and costs most to operate, while configuration costs least to build and offers no isolation. The second is that the mechanisms combine. An integration need is usually met by an adapter at the edge, an entitlement that decides who may use it and, sometimes, a dedicated stamp for the customer whose volume justifies isolation.

7. Multi-tenant architecture

The pre-work introduced the pool, silo and bridge models. In the session, two further concepts complete the picture. The first is tenant context: whatever the model, each request and each event must carry who the tenant is, its market, its tier and its entitlements, and every service must be able to read that context without querying it again. Without a propagated context, the code falls back on local checks such as the country of the order, and the same decision is taken differently in different places.

The second is metadata-driven architecture. Weissman and Bobrowski (2009) describe how the Force.com platform stored the customizations of each tenant as metadata in shared tables and generated the behaviour of each application at runtime from that metadata, so that thousands of tenants with different data models ran on one code base. The approach shows the end point of runtime binding: variants become data, and the cost moves to the design and testing of the engine that interprets them.

A global platform also deals with constraints that do not come from tenancy. Public API contracts used by many integrated systems cannot change at the pace of the platform, and latency added to a service deep in the call chain is multiplied by the calls above it before it reaches the user. These constraints often decide where a change can be made, and the worked example of the session shows how.

8. Feature flags and entitlements

Hodgson (2017) classifies toggles by their purpose and their expected life. Release toggles allow incomplete code to be deployed and exposed progressively and should live for days or weeks. Experiment toggles last as long as the experiment. Operations toggles let on-call engineers degrade or switch off a feature under load and can live for a long time. Permission toggles give some users access to a capability. The classification matters because each category has a different owner and a different removal policy.

Entitlements are not in that classification, and the omission is instructive. An entitlement expresses a contract, its owner is the commercial process and its source of truth is the record of what the customer bought. When an entitlement is implemented as a flag in the flag tool, the contract and the code drift apart, and nobody can answer which customers have which capability without reading the flag configuration.

Most common misconception

Using feature flags as a permanent mechanism for commercial differentiation. Each flag should have an owner, a removal date and tests of both paths, and each entitlement should be checked in one place connected to the contract.

9. Platform primitives

Platform engineering treats internal capabilities as products offered to the teams that build on them (Fournier & Nowland, 2024). For variability, the most useful capability is a primitive that resolves tenant and market context once and returns the policy that applies. Skelton and Pais (2019) describe the platform team as the team that reduces the cognitive load of stream-aligned teams; a tax policy primitive does exactly that, because the team that builds checkout no longer needs to know the tax rules of five markets.

The sample repository of the lab shows the situation before the primitive. The tax rule is a chain of country conditionals in the order service, the name of the tax is chosen by another chain in the interface, a reporting view repeats the chain in SQL, and a Brazilian distributor received a column created only for its contract.

Before · service/orders/pricing.py and issue.py
def compute_tax(order):
    if order.country == "BR":
        tax = order.subtotal * 0.18
    elif order.country == "MX":
        tax = order.subtotal * 0.16
    # ... one branch per market

# Urgent request from DIST-0042 (Brazil): tax substitution override.
if order.country == "BR" and order.customer.customer_id == "DIST-0042":
    rate = order.customer.dist0042_st_override
After · policy resolved from the 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.
# Customer-specific overrides live in one table with owner, cost and review date.

The primitive changes the unit of work. A new market, or a new regional rule inside a market, becomes a new policy reviewed by the owner of the rule and tested on its own, instead of a change in every layer. A golden path, the supported and documented way of building on the platform, makes the primitive the easiest option for the teams, which is what keeps new conditionals from appearing next to it.

10. AI agents for large-scale changes

Finding every place where a variation is decided is the first and most tedious step of extracting it, and coding agents are well suited to it: they search the repository, read the surrounding code and draft the refactoring. The evidence on their effect, however, recommends caution. The DORA report on AI-assisted software development (DORA, 2025) associates the benefits of AI with the quality of the practices around it, such as version control, small batches and a healthy internal platform. In a randomized trial with experienced open-source developers working on their own repositories, Becker et al. (2025) found that access to AI tools increased the time to complete tasks by 19%, while the developers believed they had been faster.

In the lab, the agent is used in five steps. It is asked to search every layer, including SQL and configuration; it is required to return an impact map with file, line and reason for each occurrence; the map is verified by hand, looking for spellings the search did not try and removing occurrences that do not belong; the refactoring is requested under stated architectural constraints, such as public contracts that cannot change; and the generated diff is reviewed as if it came from a new colleague.

The review covers security as well as correctness. Code produced by a model can introduce the same weaknesses as any code, and the OWASP guidance on applications that use large language models (OWASP, 2024) adds risks specific to them, among them the disclosure of sensitive information present in the context and the handling of model output as trusted input. In practice, the reviewer checks for credentials copied into code, dependencies that do not exist or are not approved, and tests that pass without asserting the expected behaviour.

11. The lab: three needs at Tradeline

Tradeline is a fictional global B2B ordering marketplace. Retailers such as bars and small groceries order from manufacturers and distributors in five markets, under three service models: direct, in which the manufacturer produces and distributes; manufacturer that does not distribute; and indirect, through distributors. Order issuing and catalog pricing are the services whose failure stops sales in every market. The tax rule already lives as country conditionals in three layers of the order service. Three needs arrived in the same quarter.

Need 1 · Regional tax rule at order issuing

Colombia exempts orders delivered to two departments from IVA, from a legal start date, while the rest of the country keeps the standard rate. Mexico may introduce a similar rule for border zones next year. The rule depends on the delivery address, and an order issued with the wrong tax must be cancelled and reissued.

Need 2 · Approval flow for premium distributors

About 120 premium distributor accounts in Brazil and Mexico want orders above a threshold of their choice to wait for a purchasing manager. Some want thresholds per region and one wants two approvers above a second threshold. Today every order is approved automatically.

Need 3 · ERP of a large distributor

The largest distributor in South Africa wants orders pushed to its ERP in real time and stock pulled every fifteen minutes, through a SOAP interface that changes twice a year. Distributors in Mexico and Colombia with other ERPs may ask for the same.

Steps (40 minutes)

  1. Classify each need by type of variation and binding time (5 minutes).
  2. Propose two ways to accommodate each need and assess the effects on code, deployment, testing, operations and cost, stating the missing information (15 minutes).
  3. Use the coding agent to map every occurrence of the tax conditional in the sample repository and propose its extraction into a configurable policy, verifying the generated map by hand (10 minutes).
  4. For the preferred option of each need, state what happens to the retailer and to the critical services if it fails (5 minutes).
  5. Close the sketch (5 minutes).

The deliverable is complete when each need has two options with explicit testing and operating costs. Groups of five or six work in breakout rooms with four rotating roles: a lead, who conducts the discussion; a recorder, who writes the sketch; a timekeeper; and a skeptic, who challenges assumptions and asks what each option costs to test and operate.

Differentiation by class

In Class 1, made up of developers, the lab gives more time to the assisted refactoring and to the implementation of the platform primitive in the sample repository, keeping its tests passing. In Class 2, architects lead the comparison of mechanisms and isolation models, and QA and SRE professionals assess the testability and operability of each option.

12. Lab kit and no-login alternative

FileContentUsed in
needs-brief.mdFull brief of the three needs, with the known facts of each oneSteps 1, 2 and 4
tradeline-orders-sample.zipSample repository: interface in TypeScript, order service in Python, SQL migrations and a reporting view, deployment notes and tests that run with python3 tests/run_tests.py or pytestStep 3 and the Class 1 refactoring
architecture-option-sketch-template.mdTemplate of the deliverableAll steps
impact-map-pregenerated.mdPre-generated output of a coding agent asked to map the tax conditionals, not reviewedNo-login alternative for step 3

The no-login alternative serves groups without access to Cursor or to the repository environment. The group receives the impact map that an agent produced and verifies it against the code listings of the repository, which can be read directly in the zip file. The map should be treated the way any agent output is treated in the lab: as a draft whose completeness and correctness the group must establish.

13. Architecture Option Sketch

The Architecture Option Sketch is the artifact of the session. It records, for each need, the classification, two options compared on the same criteria, what the group does not yet know, the provisional direction and the effect of a failure. Ranges and the word "unknown" are acceptable answers; the template asks for the missing information precisely so that a decision is not presented as more certain than it is.

FieldOption AOption B
Type of variation and binding timeDomain, commercial, regulatory, release or infrastructure; build, deploy or runtime, and why
Mechanism and where the variation is encapsulated
Effect on code (coupling, files touched)
Effect on deployment
Testing cost (what must be tested, how many combinations)
Operating cost (support, observability, on-call)
Isolation and blast radius
Cost (build now and run per year, as a range)
Missing information
Preferred option and provisional direction
If the preferred option failsEffect on the retailer using the app and on order issuing, catalog and pricing
What would change our mind

14. Formative rubric

The session has no grade. The rubric is read by each group against its own sketch during the debrief, and the criterion where the group is still developing becomes the focus of the post-work.

CriterionProficientDeveloping
ClassificationType and binding time of each variation correctly identifiedAll variations treated as the same
Mechanism comparisonDifferent options 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

15. Post-work

The post-work takes twenty minutes and applies the artifact to your own context. Choose a real variation in a system you work on, without confidential names, and write an Architecture Option Sketch for it: the type of demand, at least two options, their trade-offs, a provisional direction and what would change your mind. The sketch is reused in Project Development, where the groups of the program work on situations from their own teams.

The next session of the track, Workshop 2 · Code Review and Operational Excellence: Preventing Variant Debt, starts from the situation that the options of this session try to avoid: conditionals in every layer, columns created for a single customer and flags that never leave the code.

16. References

  • Apel, S., Batory, D., Kästner, C., & Saake, G. (2013). Feature-Oriented Software Product Lines: Concepts and Implementation. Springer.
  • Becker, J., Rush, N., Barnes, E., & Rein, D. (2025). Measuring the Impact of Early-2025 AI on Experienced Open-Source Developer Productivity. METR.
  • DORA. (2025). State of AI-assisted Software Development. Google Cloud.
  • Fournier, C., & Nowland, I. (2024). Platform Engineering: A Guide for Technical, Product, and People Leaders. O'Reilly Media.
  • Golding, T. (2024). Building Multi-Tenant SaaS Architectures. O'Reilly Media.
  • Hodgson, P. (2017). Feature Toggles (aka Feature Flags). martinfowler.com.
  • Microsoft. (2024). Architect multitenant solutions on Azure. Azure Architecture Center.
  • OWASP Foundation. (2024). OWASP Top 10 for LLM Applications 2025.
  • Pohl, K., Böckle, G., & van der Linden, F. (2005). Software Product Line Engineering: Foundations, Principles and Techniques. Springer.
  • Skelton, M., & Pais, M. (2019). Team Topologies: Organizing Business and Technology Teams for Fast Flow. IT Revolution.
  • Weissman, C. D., & Bobrowski, S. (2009). The design of the Force.com multitenant internet application development platform. In Proceedings of the 2009 ACM SIGMOD International Conference on Management of Data (pp. 889–896).