Dark Mode

Nick Van Exan

Software Developer

Data Structures

Some thoughts on data structures vs. code

Saw this article on HN the other day: Good programmers worry about data structures and their relationships

This quote from the article expresses the TLDR well:

Data is more tractable than program logic. It follows that where you see a choice between complexity in data structures and complexity in code, choose the former. More: in evolving a design, you should actively seek ways to shift complexity from code to data.

I agree with the title and substance of the article. And have seen it in practice.

In fact, this article came across my screen right at a time that our team had received news about requirements that, at first glance, were surprising. For confidential reasons, I can't disclose much, but I can make some analogies.

Let's say that for one section of our app our team was initially told the pages concerned the management of a model of car over a period of time. But then we learned the company doesn't think about its management processes in that way. They never care about the management of a model of car on its own; they care about the management of a portfolio of vehicles (cars, trucks, vans, etc.) for a given time period. And the addition or substraction of new vehicles to, as well as their order in, that portfolio, has impacts on costing and budgeting calculations that have to be redone whenever vehicles are shuffled in and out of the portfolio for a given time period. So now the software doesn't just concern the management of Model A. It's about the management of Model A, B, C, D, etc. and their costing impacts on each other over time.

Cool. No problem.

This new set of requirements wasn't something we had been building or specifically planned for. But we were able to say to the client "Cool. No problem." because smart senior engineers on our project had already thought enough about the domain model and what the client would generally be wanting to achieve that they structured the data in such a way that could accommodate this request easily. We might have to change how we think about the UI / UX of this section of the app (i.e. the code), but the underlying data structures and the relationships and sequencing between objects (in a linked list kind of way), coupled with a clean code architecture, made it easy to accommodate this shift.

August's Fragments

All fragments