Every dependency you add is code you didn't have to write — and also code you now depend on someone else to maintain. Neither 'never reinvent the wheel' nor 'never add a dependency' survives contact with a real decision.
3 min read
Almost every non-trivial feature has an existing library or service that claims to solve it — authentication, payments, date parsing, PDF generation. "Build vs buy" is the decision of whether to write that piece yourself or bring in something that already exists (a library, a paid service, an open-source tool) — and it's a real trade-off, not a question with a universally correct answer.
Pulling in a dependency isn't free even when it's open-source and costs nothing directly:
Writing it yourself has its own real, easy-to-underestimate costs:
Ask whether the thing in question is core to what makes your specific product valuable, or a solved problem every product like yours also needs. Payment processing, authentication, and PDF rendering are rarely what makes a product distinctive — they're usually "buy" (or use a well-maintained library). The specific business logic that actually differentiates your product from a competitor's is usually the "build" — that's exactly the part where writing custom code, tailored precisely to your case, pays off.
Neither extreme survives contact with a real project: refusing every dependency means reinventing dozens of already-solved problems badly; adding a dependency for absolutely everything means inheriting maintenance burden and security surface for things that didn't need it. The actual skill is asking the "is this core to what we do" question deliberately, case by case, instead of defaulting to either extreme out of habit.
Check your understanding
A quick comprehension check — not tracked, not graded, just for you.
1. What real costs does 'buying' (using an existing library or service) carry, beyond any direct price?
2. What real cost does 'building' something yourself carry, beyond development time?
3. What's the rough heuristic this lesson gives for deciding between building and buying?
Software Engineering Fundamentals