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
Category: Database
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
An introduction to Entity Framework
Introduction This is article isn’t a hands-on guide to getting started with Entity Framework (EF). Instead it aims to give you an understanding of what EF is, whether it’s for you, and if so, which of its options apply best to you. In the next article I will do the hands-on stuff, where I walk … Continue reading An introduction to Entity Framework
Named parameters with default values can help unit tests
Introduction I find myself using default values much more in unit tests than in production code. That is, I do it more often, and use more parameters with defaults per method. This isn't because default values are bad, but they are often particularly useful when setting data up for unit tests. It makes the tests … Continue reading Named parameters with default values can help unit tests
Automated testing of a website: Dealing with the database
This article proposes an approach to handling the fine-grained parts of the database parts of an automated system test of something like a website. You would need other things for the remaining jobs: To orchestrate the test, something like SpecFlow; To interact with the website, something like Selenium; To do the bulk updates to the … Continue reading Automated testing of a website: Dealing with the database
Reading JSON in SQL Server 2016
Introduction There's a lot of this that I won't have time or space to cover, so for more information, I suggest you look at Microsoft's blog on SQL Server + JSON. What I will cover is the OPENJSON table-valued function, which lets you turn JSON text into a result set, i.e. rows and columns. One … Continue reading Reading JSON in SQL Server 2016
Dealing with transactions in tSQLt
This is the last article in a series about unit testing SQL Server with tSQLt: Introduction Anatomy of a tSQLt test Practical considerations Dealing with transactions The problem In my experience, most code is fine to be tested with tSQLt. However, code that involves transactions will get tangled up in the transaction that tSQLt uses … Continue reading Dealing with transactions in tSQLt