In a previous article on complexity, i.e. performance trends in code, I said that trees can be useful ways of storing data, but they only work if they’re reasonably well balanced. In this context, balanced means that no path from the root node of the tree to a leaf node is much longer than any … Continue reading Balanced trees
Category: Database
Building computer systems via problems rather than solutions
When it comes to building computer computer system, even something as simple as storing the name and address of universities can be surprisingly complicated and messy. While the mess and complication often can’t be avoided, knowing what the end user needs are can help you come up with the best way of tackling them. “Just” … Continue reading Building computer systems via problems rather than solutions
Aggregation and window functions for data
In this article I’ll go into two related operations or kinds of queries you can do to data, that are both to do with grouping things – aggregation and window functions. I’ll describe how they both work, how they’re similar but different, and give examples of when you might use them including how you might … Continue reading Aggregation and window functions for data
Solving computer problems with indirection
There's a pattern that crops up a lot in computing - indirection. It's sometimes a little bit disguised, but it's used to solve many kinds of problem. To introduce it I'll first use an example from outside computing, that I like for many reasons. Five freedoms for animal welfare It might be a bit odd … Continue reading Solving computer problems with indirection
Comparing and aligning data models
Sometimes you are trying to bring two worlds together - two bits of code, each with its own data model. The two worlds could be a computer system you work on and the system from a partner you're trying to integrate with. The data models can be the most prominent bits of this integration, but … Continue reading Comparing and aligning data models
Mini roundabouts and deadlock
This is the first in a small series of articles using roundabouts to explore some ideas in computer science: Mini roundabouts and deadlockMagic roundabouts and starvation In this article I’ll go into dependency, which can lead to deadlock. For this I’ll be using the mini roundabout as an illustration. In the next article I’ll use … Continue reading Mini roundabouts and deadlock
Recursion and iteration – an introduction to iteration
This is the first of a series of articles about recursion and iteration Introduction to iterationIntroduction to recursionMutual recursion and tail recursionBlurring the linesLoop unrolling Recursion and iteration are both techniques for doing some work (or similar work) repeatedly, so that you can solve a bigger problem. This could be things like summing all the … Continue reading Recursion and iteration – an introduction to iteration
The cost of flexibility
Flexibility in software design is often seen as a good thing, but it can come at a cost. This isn’t surprising, because software engineering is a kind of engineering, and engineering involves making trade-offs among several good things. For instance, there is no “best” car, just the best car for a given situation, with a … Continue reading The cost of flexibility
Complexity: Performance trends in code
Introduction If you hang around programmers for long enough, you might hear people use terms like complexity or Big O notation, or say that performance is of the order … such as of the order N squared. I hope that this article makes those terms a bit less confusing. The basic idea is seeing how … Continue reading Complexity: Performance trends in code
Unit testing database queries
In this post I will try to describe an approach to unit testing database queries. It happened to be inspired by some testing I was doing of some C# code, but you could apply the same ideas to other languages. Note that if you’re unit testing stored procedures then I recommend using something like tSQLt, … Continue reading Unit testing database queries