Prefer Parsing Over Validating: Let The Compiler Help You Remove Edge Cases
In this blog post, I’ll discuss a technique that I’ve used to create expressive APIs that are more robust with the help of the compiler. I’m going to demonstrate a simple example of this technique in Java but anything you are about to read can be applied to any other statically typed language. Let’s start by quickly defining “parsing” and “validating”. In my mind, validation is about analyzing input and reporting if it adheres to a certain set of validation rules:...
Database Design: Avoid Derivative State
This is the beginning of a potential series on effective database design. Before we get into the nitty-gritty, let’s address the elephant in the room: what is derivative state? I haven’t heard this term being used elsewhere so I’m going to officially define it here as: Derivative state is state that can be derived from another piece of state (the parent state). By definition, this means the derived state cannot carry more information than its parent....
The Search for Home
I was raised in what I thought was a middle class family: one working father, a stay at home mother, and one younger sibling all living under the same roof of a 1 bedroom apartment in NYC. It was, relative to the global standard of living at least, a good life. We always had food on the table, clothes on our back, and a roof over our head. My parents came from a country where roughly 30% of the people cannot make the same claims as I just did....
The Case Against Std Pair
I’ve been professionally developing software with C++ for a few years now and I’ve been seeing a pattern in the C++ world that’s bothered me for quite some time now. That pattern is the use of std::pair from the <utility> header in C++’s STL in non-generic code. TL;DR Use of C++’s std::pair unnecessarily obfuscates what’s being represented in the pair when used outside of generic code. We can use simple structs instead to allow our code to become more self-documenting....
Linux - Creating a Static Library Using GCC and the Command Line
This tutorial will cover creating a static library using the command line with the GNU C/C++ compiler. We will use C++ as the primary language although a slight modification in the outlined steps can be used with the C language. Unlike most tutorials which use trivial and relatively useless functions to demonstrate building libraries, we will implement a fairly useful std::string function that is bizarrely missing from the STL - the string split (or tokenize) function and build a static library from that....