ondercode
TR EN

15 November 2026 · 16 min read

Make the Brick or Buy It? The Math of Building Your Own Framework

Should you build your own framework or use a commercial or open-source component? A break-even formula, a risk term, Brooks's 9×, the math inside a framework (animation, scrolling, virtualization, colour contrast) and a step-by-step roadmap.

  • Framework
  • Build vs Buy
  • Yazılım mimarisi
  • Açık kaynak
  • Lisans
  • C#
  • WinForms
  • Onda

A contractor building an apartment block doesn't open a brick factory. He buys bricks, lays the walls and hands over the keys. Most of the time software should work the same way: we buy the grid component, the PDF engine and the logging library, and spend our energy on what the customer actually pays for.

But sometimes nobody sells a brick in the size you need. Sometimes the supplier triples the price overnight. And sometimes you have to know exactly what's inside the brick, because the building will carry your name.

That is why I wrote Onda, my own component framework for WinForms and Blazor. This article walks through the math behind that decision, the build or buy question, and the math that runs inside a framework. At the end there's a step-by-step path for anyone who wants to write their own framework, and a list of sources you can read for free.

First, terms: library vs framework

  • Library: you call it. You write Json.Serialize(x) and you're done. You're in control.
  • Framework: it calls you. You write an OnPaint method or a page component, and the framework decides when it runs. Martin Fowler calls this Inversion of Control.

The difference matters because leaving a framework costs far more than leaving a library. A library is a brick; a framework is the building's skeleton. To replace the skeleton you have to knock the building down.

Buying (commercial or open source)

Ready-made components come in two flavours: paid commercial products and open-source packages. Either way, they are someone else's bricks.

Advantages

  • Speed: work that would take months lands in your project in an afternoon.
  • Maturity: bugs found by thousands of people were fixed before you arrived.
  • Docs and community: when you're stuck there's someone to ask and a forum to read.
  • Hiring: a tool everybody knows means a new developer is productive on day one.
  • Focus: your team's attention stays on the work the customer pays for.

Disadvantages

  • The license can change. This is no longer a theoretical risk. In the .NET world alone, in the last two years:
    • FluentAssertions, one of the most widely used testing libraries, moved from Apache 2.0 to a commercial license in version 8. Commercial use costs $129.95 per developer per year (InfoQ, January 2025).
    • AutoMapper and MediatR switched to a dual license in July 2025. There's a free community edition for companies under $5M in annual revenue; above that it's paid (Jimmy Bogard's announcement).
    • On the infrastructure side, HashiCorp moved Terraform to the Business Source License in August 2023, and the community answered with the OpenTofu fork.
  • Supply-chain risk. In 2016 one developer unpublished the 11-line left-pad package from npm, and thousands of projects, Babel and React among them, stopped building (Wikipedia). In 2021 the Log4Shell vulnerability in Log4j (CVSS 10) ruined half the world's weekend. In 2024 someone called "Jia Tan", after more than two years of building trust, planted a backdoor in the xz library; Andres Freund caught it by accident while investigating oddly slow SSH logins (Wikipedia).
  • Dependency chains. One package brings ten more. You think you bought one brick, but you've signed contracts with ten suppliers. xkcd 2347 says it in one panel: all of modern digital infrastructure resting on a single project some random person in Nebraska has been thanklessly maintaining since 2003.
  • You live inside its mould. Whatever the component can't do, your product can't do either. Your design gets tied to someone else's roadmap.
  • You look like everyone else. The grid everybody uses looks the same in everybody's app.

Building it yourself

Advantages

  • Full control: when a bug appears you don't wait for anyone's next release.
  • Exact fit: the component does what you need and nothing more, which makes it smaller and faster.
  • Zero license and supply risk: the code is yours. Nobody can change the price one morning.
  • Differentiation: while competitors ship the same off-the-shelf component, your product looks and behaves differently.
  • Learning: a developer who writes a framework sees layers that a developer who only uses one never does, and that knowledge carries into every project.

In his 2001 essay In Defense of Not-Invented-Here Syndrome, Joel Spolsky boils the rule down to one line: if it's a core business function, "do it yourself, no matter what". His example is memorable: for a while the Excel team ran its own C compiler.

Disadvantages

  • It costs far more than it looks. Fred Brooks put numbers on this in The Mythical Man-Month: turning a working program into a product others can use, documented and tested, costs about 3×; making it a system component that talks to other systems costs another 3×. Both together, which is what a framework is, comes to roughly 9× the cost of "code that works" (lecture-notes summary).
  • Maintenance never ends. Windows versions change, high-DPI screens arrive, a new .NET ships. All of that is now your job.
  • Knowledge can sit with one person. If the author leaves, the team ends up living inside a skeleton nobody fully understands.
  • No docs, samples or community. You'll write those too.
  • Opportunity cost: every month spent on the framework is a month stolen from features the customer can see.

The math, part 1: the decision

Let's put feelings aside and use numbers. I'll measure in person-months instead of money, so the calculation holds in any country and at any salary.

Build:  C_build(t) = B + m·B·t
Buy:    C_buy(t)   = E + n·L·t

B : initial build cost (person-months)
m : yearly maintenance rate (share of the initial cost)
E : cost of learning and integrating the bought component
n : number of developers
L : yearly license per developer (in person-months)
t : years

Where the two lines cross is the break-even point:

t* = (B − E) / (n·L − m·B)

Watch the denominator: if n·L ≤ m·B, meaning your yearly license bill is smaller than your own maintenance cost, t* never arrives. Building never pays off.

A concrete example: a grid component

Say you can get a good grid "working" in 2 person-months. Apply Brooks's 3× for docs, tests and edge cases: B = 6 person-months. Maintenance at 20% a year: m·B = 1.2 person-months/year. Learning and integrating a bought grid: E = 0.5 person-months.

For the license take an illustrative $1,000 per developer per year. If a developer costs $4,000 a month, that's L = 0.25 person-months. (The figures are examples; plug in your own quote.)

  • 5 developers: t* = (6 − 0.5) / (1.25 − 1.2) = 110 years. Don't build.
  • 20 developers: t* = 5.5 / (5 − 1.2) ≈ 1.45 years. After a year and a half your own component is ahead.
Cumulative cost (person-months)0510152025012345YearsBreak-even ≈ 1.45 yearsWith 5 developers, break-even ≈ 110 yearsBuild: 6 + 1.2·tLicense, 5 developers: 0.5 + 1.25·tLicense, 20 developers: 0.5 + 5·t

Same component, same price; the only difference is team size. The arithmetic is a far better guide than gut feeling.

The hidden term: risk

The formula above assumes the license never changes. The last two years showed otherwise. To account for it we use expected value:

Yearly risk cost = p · S

p : probability that license, price or maintenance gets worse within a year
S : cost of switching to something else on that day (person-months)

With p = 10% and S = 4 person-months, buying gets 0.4 person-months a year more expensive, and the break-even point for the 5-person team drops from 110 years to 12. Maybe still not enough to build, but no longer "never". For frameworks S is huge (you're replacing the skeleton); for libraries it's small. That's why risk matters most when you pick a framework.

Size doesn't scale linearly

COCOMO, one of the best-known software cost models, says:

Effort = A · (Size)^E      (in COCOMO II, typically E ≈ 1.1)

Because the exponent is above 1, a framework twice the size takes 21.1 ≈ 2.14× the effort, and one ten times the size takes 101.1 ≈ 12.6×. The lesson is simple: if you build your own framework, keep it small. Don't write a framework that does everything; write one that solves the five problems your apps share.

Innovation tokens

Dan McKinley's Choose Boring Technology is the intuitive version of the same calculation: every company has only a few "innovation tokens" to spend. Writing your own framework is one of them. Spend it where it makes you different, not on a logging library.

The math, part 2: what runs inside a framework?

Once you decide to build, you meet the math that ready-made components hide from you. Here are a few things I ran into while writing Onda.

Animation: easing curves

A button shouldn't snap to its hover colour; it should change smoothly. To do that, linear time t (0 to 1) is passed through a curve. One of the most useful is the cubic ease-out:

e(t)  = 1 − (1 − t)³
speed = e'(t) = 3·(1 − t)²   → three times faster at the start, zero at the end

The motion starts fast and slows to a stop, which the eye reads as "natural". Another important decision: instead of every control running its own timer, one central timer (ticking about every 15 ms) drives every animation, and a control drops off the list when its animation ends. With a hundred controls on screen, one timer runs instead of a hundred. easings.net is a great free reference for comparing curves.

Smooth scrolling: exponential approach

When you turn the mouse wheel, a list shouldn't teleport; it should glide. The simplest and surprisingly pleasant method is to cover a fixed fraction of the remaining distance on every frame:

y ← y + (target − y) · k        (e.g. k = 0.3)
remaining after n frames = d₀ · (1 − k)ⁿ

For a 1,000-pixel scroll to get within 0.5 px you need n = ln(0.0005) / ln(0.7) ≈ 21.3, so 22 frames. At 15 ms per frame that's roughly 330 ms: fast enough to feel responsive, slow enough to feel smooth. A subtle detail: frame times vary, so a careful implementation uses 1 − (1 − k)^(Δt/15) as the fraction, which makes scrolling independent of how fast the machine is.

Virtualization: drawing 100,000 rows with 17

Drawing all 100,000 rows of a grid freezes the screen. But only a few dozen rows are ever visible at once:

first_row = ⌊ scroll_y / row_height ⌋
rows_drawn = ⌈ visible_height / row_height ⌉ + 1

With 38-pixel rows in a 600-pixel area, that's 17 rows. Drawing cost becomes proportional to screen size, not row count: O(visible) instead of O(n). That's what off-the-shelf grids call "virtual mode".

Chart axes: "nice numbers"

If a chart's maximum is 3.95 million, the axis shouldn't read 0, 0.9875, 1.975… but 0, 1, 2, 3, 4 million. Paul Heckbert's 1990 method, Nice Numbers for Graph Labels, works like this:

raw_step = max / 4                          → 987,500
exponent = 10^⌊log₁₀(raw_step)⌋             → 100,000
fraction = raw_step / exponent              → 9.875
nice     = first of {1, 2, 2.5, 5, 10} ≥ fraction → 10
step     = nice · exponent                  → 1,000,000

So the axis is always divided into steps a human can read.

Colour: blending and legibility

Theme shades (hover, selected) are produced by linear blending between two colours: C = A + (B − A)·t. But careful: on-screen sRGB values aren't linear in actual light intensity. Blending directly in sRGB isn't a physical mix of light, and the midtones of a gradient can look darker and muddier than expected. For precise work you linearize first.

For legibility there's a ready formula, the W3C's WCAG relative luminance definition:

c_linear = c ≤ 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055)^2.4
L        = 0.2126·R + 0.7152·G + 0.0722·B
contrast = (L_light + 0.05) / (L_dark + 0.05)

Normal text needs at least 4.5 : 1. If you're writing a theme engine, testing every text colour against this formula in both light and dark mode saves you a pile of user complaints. The fact that green's weight (0.7152) is ten times blue's (0.0722) also shows how sensitive our eyes are to green.

Layout: constraint solving

For a simple framework, rules like "dock left, fill the rest" are enough. But once you want "this button is always 8 px right of that one and both are centred", layout turns into a system of linear equations. The Cassowary algorithm behind Apple's Auto Layout solves those systems incrementally at every window size. If your framework doesn't need it, and most don't, leave it out. Remember the COCOMO exponent.

Turkish: where the off-the-shelf brick breaks

One of the best examples of when you must make your own brick is my own alphabet. On a Turkish system "title".ToUpper() becomes "TİTLE" and "FILE".ToLower() becomes "fıle". The problem is famous enough to have a name, the "Turkey Test", and Jeff Atwood gave it a whole post, What's Wrong With Turkey?. A grid whose search box finds "Işık" when you type "ıs" and "İstanbul" when you type "is", and that sorts words starting with "Ç" after "C" and before "D", is hard to find off the shelf. That's why I wrote the Turkish search and sorting in the OnderCode apps' shared core myself.

So how do you write your own framework?

The path I followed and recommend:

  1. Don't write a framework first; write apps. When you write the same code a third time, extract it. That's the rule of three. Projects that start as "a framework" on day one usually fill up with abstractions nobody needs.
  2. Keep the core small. Onda's core is the theme, a base control class, drawing helpers and the single animation timer. Everything else (grid, charts, date picker) sits on top. Today Onda is about 48 files and 6,600 lines, and staying small is a deliberate choice.
  3. Design the API as a user. Write the code that uses the component first, then the component. Nobody likes an awkward API, not even its author.
  4. Keep a sample app. A demo where every component is alive is half your tests and half your docs.
  5. Use it in real products. Onda runs the hotel, parking and pharmacy apps in OnderCode Suite, OnderCode Hardware, and through its web edition Onda.Web, OnderCode Cinema. Nothing tests a framework like shipping real products with it.
  6. Version it and keep your promises. Use Semantic Versioning: a breaking change bumps the major version. Your framework is a supplier, even to you.
  7. Keep your own dependencies near zero. A brick that leans on someone else's brick brings back every risk listed above.
  8. Know when to stop. If a component doesn't differentiate your product and the ready-made one works well, use the ready-made one.

8 questions for the decision

Question If yes
Is this component core to my product, something the customer sees and pays for? Build
Do existing options cover at least 80% of what I need? Buy
Is my team large, with a license bill that grows every year? Run the break-even math
Would a license change or an abandoned project stop me? Add the risk term
Does the off-the-shelf component fit my language, regulations and culture? If not, build
Is there someone to write it and maintain it for years? If not, buy
Is my time on this worth more than shipping features to customers? If not, buy
If there's an open-source option, is it healthy? Measure it with OpenSSF Scorecard

Conclusion

We don't have to make bricks just because we're building something. Most of the time the smartest move is to buy a good brick from a good supplier. But once the brick's price, size or contents start deciding the fate of the building, it's time to build the kiln. The difference is making that call with arithmetic.

For me Onda was that kiln: a core that shapes how my products look and behave, whose price nobody can change one morning, and that speaks Turkish properly. The apps' source code is on GitHub, and you can download and try them all from the projects page.

Free sources

More on this topic: A guide to modern WinForms and Architecture for a WinForms ERP.

Comments

No comments yet. Be the first to share what you think.

Leave a comment

Comments appear after I review them.