1 hour ago · 6 min read1126 words · Tech · hide

Databases are for storing global variables. We usually call them “rows” or “records” instead, but they’re definitionally global variables: any part of your program can read or write them. Isn’t this kind of weird? It’s common programming advice that global variables are bad, and yet many elegant programs rely on databases. Either the common advice is wrong, or there’s something special about databases that makes them the exception to the rule. What’s so bad about global variables? Here’s the two main1 reasons, in my view: They allow any part of your program to implicitly send data to any other part instead of passing it around via function signatures They couple different parts of your program: if one part depends on a variable having some value, any other part can break it Both of these apply to databases. Any part of your program that makes a query can send and receive data from any other part of your program. In practice this happens all the time: one function will save some data…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town