Skip to main content
CFDLAcademy
All chapters

Part 2 · The core language · Chapter 14 of 28

Multi-file models and style

Every model so far fit in one file. Past about a dozen streams, a single file is too long for a reviewer to read as one document. This chapter covers organizing a model: how the language splits files and, as the larger subject, the style rules that make a model something colleagues can review, inherit and rely on. This chapter adds no expressive power. It adds the property that determines how long a model stays in use: whether the next person can read it.

The import graph

A model is a directory with one root file — model.cfdl — that declares the header (version, model, time, any pack) and imports the rest:

version 0.1
model "office-deal"
time calendar monthly from 2026-01 for 60

import "structure.cfdl"
import "revenue.cfdl"
import "financing.cfdl"

An imported file contains declarations and no header. Every declaration can be written in an imported file: entities and their fields, assumptions of every shape, streams, contracts, lifecycles, accounts, events, options, waterfalls, metrics, slices and statements. version, model, time, and use pack belong to the root alone, stated once for the whole model.

An import may also carry an alias, import "contracts/lease.cfdl" as lease. Imports resolve relative to the file that declares them, must stay inside the model's directory, and may not form cycles. The compiler refuses an import loop or an escape from the model root, naming the file. A model is therefore always a self-contained tree you can zip and send, and it compiles identically elsewhere.

Beyond that, placement is free: the model compiles exactly as if every file were concatenated. Declaration order never carries meaning (chapter 8 established that for rules; it is true globally), so splitting affects only communication. The question is therefore not how to split, but where.

A layout that mirrors review

Split by what a reviewer wants to read together, not by construct type. The layout that recurs across well-organized deal models:

  • model.cfdl — header and imports. A table of contents: it lists what the model contains.
  • assumptions.cfdl — every assume, together. Chapter 6's assumption page, now literally a page. Most reviews start and end here.
  • structure.cfdl — the cast: entities, their fact fields, their rule fields. The deal's balance sheet of things.
  • One file per economic subject — revenue.cfdl, opex.cfdl, financing.cfdl, exit.cfdl: the streams, events, and waterfalls of one storyline, together. The lender reads financing.cfdl top to bottom and sees every flow that concerns the lender; the file boundary is the review boundary.

The anti-pattern is splitting by construct — all streams in one file, all events in another — which scatters each storyline across every file and makes no single file readable alone. If a file cannot be summarized in one sentence ("the debt and its lifecycle"), the split is wrong.

Naming as taxonomy

Chapter 2 said stream names are yours to design; in a large model, that design either helps or hinders review. The working rules:

The first segment is the subject — tower.rent, loan.interest, fund.mgmt_fee — so sorted output groups by storyline and a glob like tower.* means something. Keep subjects aligned with your file layout and the model's organization is self-describing: the reader who sees loan.interest knows to open financing.cfdl.

The last segment is the economics — rent, interest, capex, promote — the word a statement line would use. Middle segments only when a real hierarchy exists (tower.retail.rent for the retail suite of a mixed-use building).

Fields are nouns on their owner (asset.tlb.balance), events are their trigger (refi.trigger), waterfall steps are the document's own words (servicing_fee, class_a_interest) — transcription, chapter 11 argued, is review.

Style: the house rules

The house rules this course has followed, stated once as a checklist — the review standard for every model from here to the capstone:

  1. Put dates in phases. Streams reference phase_start/phase_enter; the phase block at the top of model.cfdl is the deal's entire calendar. (Chapter 9's slip test: one date edit re-derives the model.)
  2. Put opinions in assumptions. A number in an expression is structure; anything a committee might debate reads from inputs.*. (Chapter 6's four tests.)
  3. Write expressions that read aloud. Structure over results, names over repeats, decomposition over cleverness. (Chapter 5's three habits.)
  4. Make comments state claims, not mechanics. // Net-45 per the MSA, signed 2026-03 states a claim; // multiply rent by occupancy restates the code. The best comments cite the document the claim came from — the model as annotated deal file.
  5. Hand-check one number per file. The chapter-3 habit, scaled: each economic file's total, verified once by hand, noted in a comment. When every file carries a checked anchor, the next error is localized to one file.

The compiler enforces none of these. They are what the compiler cannot check, which is why they belong to style. A team that adopts them gets models that can be reviewed like documents; the capstone is written to this standard so you can read a full deal built this way before writing one.

What can go wrong

An import cycle. revenue.cfdl imports opex.cfdl which imports revenue.cfdl — refused, with the cycle's path named. Cycles between files are always a layout defect (the declarations themselves cannot be circular anyway): merge the files or move the shared piece to structure.cfdl.

A path outside the root. import "../shared/rates.cfdl" is refused. Sharing across models is a real need with a real answer — packs, Part III — not a relative path that makes a model's meaning depend on whichever files are next to it.

A split that hides a duplicate. Two files each declare a tower.insurance stream — refused as a duplicate, exactly as in one file. The compiler reads the concatenation; the files are for readers.

Exercises

Exercise

Pay the style debt

The model computes the right numbers and fails the checklist: dates copied into three schedules, three opinions buried in expressions.

  1. Apply rule 1: phases.
  2. Apply rule 2: an assumption page.

Note one effect. The fitout cost sits in February, mid-phase, and phase_enter("fitout") places it at the phase's start — January. Cash moves one month earlier, so the NPV changes slightly while the total does not change. The trade is correct: the February date recorded no reason, while "when fitout begins" is a claim that remains correct if the timeline moves. The expected metrics are the refactored model's, for exactly this reason.

Loading exercise…

Then, on your own:

  1. Take your chapter-9 venue model and split it: assumptions, structure, operations. Confirm that every series and every figure is identical to the single-file version . The split affects only communication. The model_hash stays the same too. The compiled model records which file each declaration came from, but where a declaration is written is not part of the model's identity, so a moved declaration is the same model with the same cash.
  2. Apply the five-rule checklist to the most recent model you wrote before this chapter. Score it strictly, fix the two cheapest violations, and note how long each took — a style violation costs least to fix immediately.