I'm sort of used to React hooks now. I'm not sure how I feel about them. Sometimes good, sometimes not so confident. But I like them enough to essentially not use class components anymore.
One thing I keep wondering about is where to use them. They seem like they'd make a easy shortcut to avoid container components. Often I end up passing props from hooks to functional components anyway. So maybe that would be best.
On the other hand, you're then on the, hah, hook, for carrying the effects and state it uses indefinitely. It also makes unit testing clumsier since it often requires a mock somewhere, which is a bit tedious.
One idea while writing this – Implement one module with two components. One is the core visual/functional component and the other sets up the hook and other effects.
My last blog has been long ignored. I had recently become more interested in having a more convenient way to write from my phone, as well as my computer. I am still interested in self-hosting/VPS hosting too.
So now, I'm starting up this new blog with WriteFreely and self hosting it. There were quite a few bumps along the way, and given how the past 12 months have been, it's taken me a real long time to get solid chunks of time to stand it up. But here we are!
I've been able to import a few entries back into Writefreely. Lucky for me I chose to use Markdown for writing in general. So you can scroll back and check out older entries. For now too, my previous writing spot works fine too.
If this fact alone doesn't make you sigh, well, thanks for your understanding. Here was today's unexpected adventure.
To recap Part 2, we built ourselves a BST to track our favorite usernames. This lets us add, remove, and find these usernames in “logarithmic time” which means the amount of stuff we look at is cut in half at each step.
However, we saw one of the issues with the plain BST. The performance is directly impacted by the order elements are added. This isn't great. So let's explore an option to overcome this limitation which is generally speaking known as a self-balancing binary search tree. Our specific pass at it is known as a AVL BST.
To recap our story, we love usernames. We collect them, and so do our friends. We love to compare our lists of usernames together to see how they're similar. This is tedious though, so we decided to sort it and search through it. Much better, but keeping this list sorted is a project in of itself.
So let's build ourselves a method to keep better track of these lists. We'll implement what's called a Binary Search Tree for this.
A brief moment on copy-paste. Copy-pasta, if you're into that kind of dish.
I whine about copy-paste often. I whine about it at work a lot. I whine about it to the point where the joke “look out, pseudoramble will be angry if he sees you copying-and-pasting!” is a fan favorite.
I have my reasons for whining about copy-pasta (mainly that I've made these mistakes). I wanted to make my own thoughts both more clear and less hard-line than I've managed to set myself up for.
Something that's easy to forget in the world of software development is that testing is a major time investment. Testing has a variety of meanings depending on the context of course. But here we mean attempting to show software correctness by exercising code.
I've recently been poking around at a form of testing known as property-based testing.
“Property-based tests make statements about the output of your code based on the input, and these statements are verified for many different possible inputs.”
Property-based looks at the input & output of a function to describe details about the output itself.
A description is provided for the parameters needed for that function. Test data is then
generated from these descriptions, which helps tease out harder-to-find scenarios.