I have used StyleCop for years. The project started back in the mid-2000s as an internal Microsoft tool, was released to the world in 2008, and became open source on CodePlex in 2010. As you can imagine, coding style can…
Redecorating with C++
The decorator pattern is one of the classics in the Gang of Four Design Patterns book. Let’s explore this pattern first with a C# example. This is just your average decorator, which as the code comments say, employs inheritance and…
Letter Boxed: Rust impl, part 4 (complete solver)
After some incremental progress in our Letter Boxed solver, we’re now ready to complete the app. Our hard-won “expertise” in Rust now makes the last several steps largely mechanical. The first set of changes produces LetterBox and Vertices structs, so…
Letter Boxed: Rust impl, part 3 (modules, trie, I/O)
Our Rust-based Letter Boxed code so far has just the core character-based data types. Today we’ll add the trie. Before we move on, we need to keep our house in order. Rather than have one massive lib.rs file, we should…
Letter Boxed: Rust impl, part 2 (panicking, hashing, parsing)
Previously we began our Rust exploration of Letter Boxed with the core St and Ch structs. Now we’ll complete their functionality. The next test on our TODO list looks like this in the C# version: We’ve already encountered our first…
Letter Boxed: Rust impl, part 1 (basics)
We’ve already set up the development environment, so let’s write some Rust code! A good place to start is with the bottom layer data structures, known as Str and Ch in the C# version. To review, Ch is an enumeration…
Watching a directory: debouncing
Over the last few posts, we have created a relatively full-featured DirectoryWatcher library, but it has one glaring omission. To demonstrate, let’s review the output of the sample program which randomly modifies the files it is watching: For many types…
Watching a directory: composability
Last time, I mentioned that our DirectoryTreeWatcher code demonstrates composition but not composability. To see what I mean, imagine that you wanted to add logging so you could track whenever a subscription is created or destroyed. A nice separation-of-concerns way…
Watching a directory: composition and thread-safety
We have a testable DirectoryWatcher; now what? Given that the DirectoryWatcher can only watch files in a single directory, we can extend this to a whole directory tree. Perhaps the best way to achieve this is with composition (in the…
Watching a directory: testability
Previously, I introduced DirectoryWatcher but it was woefully untestable. Tight coupling to the file system is something that would be at odds with a microtesting practice as described by “Geepaw” Hill. I agree with him and nearly always avoid extraneous…