Yesterday, I somewhat implemented the Chain of Responsibility design pattern in C++. This was because I grew tired of writing code that constantly called into some C library, checked an error code, and continued on to call another function IF the error was not present. This lent itself naturally (in my opinion) to a Chain of Responsibility pattern, though I may not have implemented it perfectly. Chain of Responsibility This design pattern can be boiled down to one idea: a chain of handlers working together to form a “super” handler of sorts.
Author’s note: If you like this post, consider supporting at patreon.com/windlejacob12. I love writing, and sharing what I’ve learned. I’d love to spend the majority of my time doing it! I’ve been working on a contact lately with a local startup in Johnson City, to implement infinite scrolling in their application. The codebase is entirely generated via FlutterFlow, and being generated by a low-code tool it’s a ball of spaghetti.
I’m currently reading a book by John Ousterhout, called A Philosophy of Software Design, and this book preaches one central tenant: reducing complexity. This is something near and dear to my heart, being someone that frequently works on his own projects. Complexity can kill projects and companies entirely, because the cost of engineering new software is just too high. I’ve seen it several times, and each time I’ve wanted to rail against it.
Working on a project that I currently have, I’ve found myself needing some mutual exclusion in dealing with some hardware devices. I could have gone the singleton route, where I only keep one device representation in memory at a time, but the internet and stack overflow have both told me how I am oh so wrong for wanting that. Thinking then about how I can support multiple devices in the future, while maintaining a single-device for now in a thread-safe manner, I’m forced to use mutexes to protect critical sections of code.
TIL how to implement a routing component using Re-frame and Reagent in CLJS. This has been one of the joys for me in using CLJS, things that seem like they would be complicated on the surface, end up being just a few lines of code. With this routing component, the key is to have the current page key as a symbol in the Re-frame state (sweet sweet re-frame.db/app-db), then to subscribe to that state in our component that does the routing.