BACK TO JOURNAL
July 08, 20265 min read

The Intersection of Mathematics & Code: Decomposing Abstract Problems

How studying algebraic structures and formal proofs helped me write cleaner APIs, design resilient DB schemas, and think from first principles.

MathematicsComputer ScienceSoftware Design

As a Mathematics student, I spent a lot of my first year learning to write rigorous mathematical proofs. In abstract algebra, you learn that you cannot assume *anything* that has not been explicitly proven. Every step must follow logically from the axioms.

When I started teaching myself web development, I realized that writing code is essentially the same thing: constructing a proof using code.

1. DB Schema Design as Set Theory

In mathematics, sets are collections of distinct elements. When modeling database collections, particularly in NoSQL like MongoDB, you are defining mathematical relationships (one-to-many, many-to-many). For instance:

  • A blood donor registry has a set of users, a set of donation requests, and a set of matches.
  • In my project LifeDrop, I had to ensure that role-based permissions were strict. Rather than using ad-hoc checks, I approached permissions as mappings. This rigor helped prevent critical bugs where one user role could perform updates meant only for admins.

2. Decomposing Complex API Functions

If you can decompose a mathematical statement into lemmas, you can decompose a complex backend process into clean, isolated controller files. In Express.js, writing middleware functions is the equivalent of composing functions:

f(g(x))

Where $g(x)$ checks auth status, and $f(x)$ handles the request logic. Keeping them pure and decoupled ensures that your code is predictable and easily testable.

3. The Power of First Principles

Self-teaching coding alongside a mathematics degree has made me less reliant on boilerplate copy-pasting. When a bug occurs in a MERN stack application, I don't just change variables randomly. I isolate the problem space, state my hypotheses, and check the logs. This analytical mindset has saved me hundreds of hours of debugging.

S

Showaib Hossain

Mathematics Honors & MERN Developer

Get in touch →