The Curated Daily
← Back to the archiveDispatch · 7 min read
Dispatch

Prefer duplication over the wrong abstraction (2016)

By the editors·Sunday, June 21, 2026·7 min read
Clipboard with stock market charts and graphs representing financial data analysis.
Photograph by Leeloo The First · Pexels

In the world of finance, where millions – and often billions – are on the line, the pursuit of elegant solutions is strong. We want models that capture the essence of markets, algorithms that predict future performance, and systems that automate complex processes. However, a deceptively simple principle from software development, articulated by Kent Beck, can be a powerful guide: prefer duplication over the wrong abstraction.

This principle, often discussed in the context of coding, is surprisingly relevant – and often ignored – in the financial industry. It's a warning against the temptation to prematurely generalize, to create overly complex models, or to abstract away detail before fully understanding the underlying realities. Let's explore why this is so important, and how applying this principle can lead to better investment decisions, more accurate risk assessments, and more robust financial systems.

What Does "Prefer Duplication Over the Wrong Abstraction" Mean?

At its core, the principle argues that copying and pasting code (or, in our case, replicating logic in different financial models) is often better than forcing everything into a single, overarching abstraction that isn't quite right. Why? Because a flawed abstraction can introduce subtle errors, obscure important nuances, and ultimately lead to incorrect conclusions.

Think of it like this: Imagine you need to calculate the present value of a single cash flow for two different projects. One project is a short-term venture with a known discount rate, while the other is a long-term investment with a more uncertain rate.

  • The Wrong Abstraction: You might try to build a single, highly flexible present value function that attempts to handle all possible discount rate scenarios, complexities of compounding, and even inflation adjustments. This sounds great in theory, but it quickly becomes complex and prone to errors. A slight mistake in the generalized formula can propagate across all calculations.

  • Preferring Duplication: Instead, you could create two separate present value calculations, each tailored to the specific needs of its project. This might mean duplicating some underlying formulas, but it ensures that each calculation is accurate and appropriate for its context. It's less elegant, but significantly more robust.

Why is This So Important in Finance?

Finance relies heavily on models – mathematical representations of reality. These models are, by definition, simplifications. The danger arises when those simplifications become misleading. Here’s how the preference for duplication safeguards against common pitfalls:

  • Model Risk: Financial models are never perfect. The complexity of markets and human behavior means there will always be limitations. A poorly conceived abstraction amplifies model risk. By favoring duplication, we limit the scope of any single abstraction, reducing the potential for catastrophic errors.
  • Data Quality: “Garbage in, garbage out.” Financial data is notoriously messy. Abstraction can mask underlying data quality issues, leading to confident but incorrect decisions. Duplication forces you to confront the data's quirks in each specific context.
  • Changing Market Conditions: Financial markets are dynamic. An abstraction that works well in one environment might be completely wrong in another. Duplication allows for greater flexibility to adapt to changing conditions without dismantling a complex, overarching system. You can modify a specific calculation without impacting others.
  • Lack of Transparency: Complex abstractions can be opaque, making it difficult to understand why a model is producing a particular result. Duplicated, simpler calculations are easier to audit and debug.
  • Premature Optimization: The pursuit of elegant, efficient code (or financial models) can sometimes come at the expense of clarity and accuracy. "Premature optimization is the root of all evil," as Donald Knuth famously said. This holds true in finance. Focus on getting the calculations right first, and then optimize if necessary.

Practical Examples in Finance

Let's look at some real-world examples where preferring duplication would have been beneficial:

  • Credit Risk Modeling: Building a single credit scoring model for all loan types (mortgages, auto loans, credit cards) can be tempting. However, each loan type has unique risk factors. A better approach might be to build separate models, even if it means duplicating some core logic. https://example.com/ (e.g., a book on credit risk modeling).
  • Portfolio Optimization: Trying to create a "one-size-fits-all" portfolio optimization algorithm that accounts for every possible investment goal and risk tolerance is likely to fail. It's better to build separate optimization routines for different client profiles.
  • Derivatives Pricing: Complex derivatives often require specialized pricing models. A generic pricing engine might be inaccurate or inefficient. Duplicating core numerical methods and adapting them to specific derivatives can be more effective.
  • Algorithmic Trading: High-frequency trading strategies often exploit very specific market anomalies. Trying to build a single, adaptable algorithm can be less profitable than creating multiple, specialized algorithms.
  • Backtesting: When backtesting trading strategies, resist the urge to generalize across different time periods or market conditions. Backtest each strategy independently to avoid spurious results.

When Is Abstraction Appropriate?

This isn’t to say that abstraction is always bad. Abstraction is essential for managing complexity. The key is to apply it at the right time, and at the right level.

Here's when abstraction is generally appropriate:

  • After Thorough Understanding: Only abstract when you have a deep understanding of the underlying problem and its nuances.
  • Identifiable Commonality: Abstraction should be based on genuine commonalities, not forced generalizations.
  • Testability: Abstractions should be thoroughly tested in isolation to ensure they are accurate and reliable.
  • Maintainability: The abstraction should simplify the overall system and make it easier to maintain.
  • Clear Boundaries: The abstraction should have well-defined boundaries and clear inputs and outputs.

A Table Summarizing the Key Differences

| Feature | Prefer Duplication | Wrong Abstraction |

|---|---|---| | Complexity | Simpler, more focused | Complex, overarching | | Accuracy | Higher, tailored to specific context | Lower, prone to errors | | Maintainability | Easier to modify and debug | Difficult to change without causing unintended consequences | | Transparency | Easier to understand | Opaque, difficult to audit | | Adaptability | More flexible to changing conditions | Less adaptable, requires significant rework | | Risk | Lower model risk | Higher model risk |

Recognizing the Temptation: Cognitive Biases at Play

The drive towards abstraction isn’t just a technical problem; it’s also a cognitive one. Several biases can push us towards premature abstraction:

  • Confirmation Bias: We tend to seek out information that confirms our existing beliefs. If we believe a particular abstraction is correct, we might ignore evidence to the contrary.
  • Overconfidence Bias: We often overestimate our ability to understand complex systems. This can lead us to create abstractions that are overly simplistic and inaccurate.
  • The Halo Effect: If we are impressed by a particular model or algorithm in one context, we might assume it will work well in others.
  • Loss Aversion: The fear of being wrong can lead us to create abstractions that are designed to protect our ego rather than accurately model reality.

Tools and Techniques to Help

Several tools and techniques can help you avoid the trap of premature abstraction:

  • Iterative Development: Build models incrementally, starting with simple calculations and gradually adding complexity as needed.
  • Unit Testing: Thoroughly test each component of your models in isolation.
  • Code Reviews: Have colleagues review your models to identify potential flaws.
  • Documentation: Clearly document your models, including their assumptions, limitations, and inputs/outputs.
  • Version Control: Use version control systems (like Git) to track changes and revert to previous versions if necessary.
  • Model Validation: Regularly validate your models against real-world data.

Conclusion

In finance, the pursuit of elegance should never come at the expense of accuracy and robustness. Kent Beck’s principle – “prefer duplication over the wrong abstraction” – is a powerful reminder that sometimes, the simplest solution is the best. By embracing duplication, we can reduce model risk, improve data quality, and build more reliable financial systems. It's about focusing on getting the details right, even if it means sacrificing a little bit of elegance. Consider investing in resources on robust financial modeling techniques. https://example.com/ (e.g. a book on financial engineering). Remember, in the world of finance, a small error can have significant consequences.

Disclaimer: This article is for informational purposes only and does not constitute financial advice. The author is not a financial advisor. Any investment decisions should be made after consulting with a qualified financial professional. Affiliate links are included; if you purchase through these links, we may earn a commission at no extra cost to you.

Image Suggestions:

  • Image 1: A photo of a complex, tangled web representing overly complicated financial models. (
  • Image 2: A split image – one side showing messy, duplicated code, the other side showing a sleek but potentially flawed abstraction. (
  • Image 3: A picture of a magnifying glass over financial data, highlighting the importance of detail. (
  • Image 4: A graphic representing iterative development, showing a process of building something up step-by-step. (
Pass it onX·LinkedIn·Reddit·Email
The Sunday note

If this was your kind of read.

Sign up for the morning email — short, hand-written, and sent only when there's something worth your time.

Free, sent from a person, not a system. Unsubscribe in one click whenever.

Keep reading

The archive →