Not all editing tools are created equal. Combining several simple ideas into one compound one, and thus all complex ideas are made - John Locke, An Essay Concerning Human Understanding (1690) While many words have been spent on the Holy Editor Flame Wars, I’ve read very little that attempts to categorize what they actually do. Likewise, everyone pays homage to the concept of using the…
F# provides a clear way to simplify invalid states with discriminated unions. Interdependent enums and booleans are a symptom of a design that could be simplified. Many domain records and classes contain enums and booleans that change in a “single transaction”. These are interdependent and often allow many states that are not valid for the business. Often they are designed this way…
I am working through the amazing Data 61 Functional Programming Course (seriously, put it on your list!) and I found myself doing a repeated set of actions. Repeated sets of actions are perfect for automation! The course has some sections with comments indicating the expected behavior: -- >>> parse (satisfyAll (isUpper :. (/= 'X') :. Nil)) 'ABC' -- Result >BC< 'A' -- -- >>> isErrorResult (parse…
Good design must be measurable Good software design should be scientific, universal, and measurable. Saying “this code is good”, or “this code is crap” is useless if we cannot even agree on what is good design. Design philosophies like “Single Responsibility Principle” can’t be objectively measured. The programmer must interpret if the code they are…
Part 3 of the series OO-Design As discussed in the previous post Anemic Domain Models Are Healthy, encapsulation makes code harder to test. We should make important actions easy to do, and testing is important. Encapsulation and domain modeling are separate concepts. A good domain model is possible with or without encapsulation. Encapsulation is the design of trust boundaries between programmers.…
TL;DR: Made a website for optimizing Paragon cards using the GNU Linear Programming Kit and Haskell. Code available here. I love MOBA’s (Dota, LoL, Paragon), and I love Haskell. Since Paragon is my current go-to game, I wanted to determine the cards to buy to maximize my Damage Per Second (DPS). First things first, I found a spreadsheet of all the cards, colors, costs, and stats. Using some…
In this series I practice reading computer science papers by following a modified set of steps outlined in the guide: How to read and understand a scientific paper: a guide for non-scientists. If your reaction to this post is ‘eh, just read the paper’, then this post isn’t for you ;) Why Should I Read The Byzantine Generals Problem? The research in this paper allows blockchain…
Trigger warning: this is a silly rant I wrote a few years ago after raging at the Hugo blog engine for a couple hours. I think its funny and still relevant, so hyperbolic nonsense incoming! DSL’s (Domain Specific Languages) are often terrible. Each DSL is a special snowflake, delicately floating from the heavens straight into in your eye. The problem with a DSL is that it always starts so…
Design Patterns and Domain Driven Design are two of the most dangerous books a new developer can read. The books themselves are not bad. They offer standardized names for common programming practices, which has made communication a lot easier for everyone. Sometimes you will see that a pattern is merely a new name for something you may have already invented. Perhaps what you were calling a…
Day three working through Software Foundations with Coq. Since I like to rant, and I love Darkest Dungeon, ENTER THE DARKEST PROOF. (Please don’t sue me!) I am trying to prove a helper proof to use to rewrite another helper proof to use to rewrite another proof for the commutativity of multiplication. You can’t make this stuff up. I just need to prove this where S n is n + 1:
My team has a decade of experience applying self-organizing teams and pair-programming to reduce wasted productivity in an enterprise banking application. The Benefits No Technical Lead Our self-organizing practices eliminate the need for a technical lead who assigns and follows up on work. No work is assigned to any individual. Individual Empowerment Developers are free to remove pain points as…
Day two working through Software Foundations with Coq. Since I like to rant, and I love Darkest Dungeon, ENTER THE DARKEST PROOF. (Please don’t sue me!) Naming While trying to understand how rewrite works, I come across an obvious use-case: Theorem adding_n_Sm : forall n m : nat, n + S m = S n + m. Proof. intros n. induction n. simpl. reflexivity. simpl. rewrite <- IHn. At this point, in…
Day one working through Software Foundations with Coq. Since I like to rant, and I love Darkest Dungeon, ENTER THE DARKEST PROOF. (Please don’t sue me!) Precise Syntax I copied a sample from the book by hand, but it always caused Company-Coq to go into an infinite loop. I copied it again. Same deal. This isn’t my first rodeo, I’ve seen all sorts of syntax rules and such. But…
Part 2 of the series OO-Design The Anemic Domain Model is often quoted as an anti-pattern in the terminology of Domain-Driven Design. Martin Fowler goes so far as to term the alternative a “rich domain model”. A rich domain model makes perfect sense until you attempt to write your first unit test. You discover that rich domain models are very hard to test. Most examples of unit-testing…
Part 1 of the series OO-Design The SOLID patterns are not enough to design a reusable and testable code base. Two concrete additions can significantly improve your codebase, while maintaining the SOLID principals. The suggestions here do not run counter to traditional SOLID designs, they enhance them. SOLID is a fine place to start, but it lacks a critical half of good design: polymorphic data.…
My current team has pair-programmed and followed strict TDD on a single codebase for over ten years. The practices started from reading the literature on Extreme Programming, which resonated with both the developers and leadership. As the team changed, we continued to follow the practices. In the last five years, the developers choose to implement Arlo Belshee’s “Promiscuous…
Editor macros are a secret weapon for editing text. While they are hard to learn, no other tool offers such broad speed and power for automating changes. A skilled macro wielder can make huge changes to a codebase with ease. Here are some inspirational patterns to demonstrate major structural refactorings using Vim macros and search/replace commands. Reorder A List Of Numbers A change left me with…
Dependency Injection can be greatly simplified while retaining all of its power. The Unnecessary Boilerplate Injection of an interface through the constructor is a common way to replace a dependency for unit-test mocking. Unfortunately, it is an extremely verbose pattern. Look how much boilerplate is needed just to mock out a call to DateTime.Now: 1public interface ICurrentTime { 2 DateTime…
(Want to become a Vim expert? Check out my new book: 10 Minute Vim) I was recently inspired by a comment from a respected coworker: “I am just as productive with basic Vim commands as I am with a refactoring suite like ReSharper.” I have pair-programmed with him for hundreds of hours of C# development. He is equally productive with both, that much I know. On some tasks he is less…
Part 2 of my series “Wrangling State”. Part 1 Wrangling State In Clojure Haskell is a pure language, so you can only deal with application state by passing parameters to functions. It is possible to pass parameters more conveniently, but ultimately, every parameter needs to be passed. Here is a simple application for logging a timestamp to a file. First, Pass As Parameter: loadFile ::…
In “Using Angular2 in Clojurescript” I showed how to get ClojureScript to run an Angular2 template. Basic hotswapping worked, but state was lost on each load. Tweaking the original demo allows for figwheel to swap in the template without losing client state. Here is a demo of hotswapping with state preservation: In this demo, we add three things to a list, then change the template that…
Getting ClojureScript to run Angular2 is not very difficult. Here is a sample project demonstrating a working Angular2 site using Figwheel for hot-reloading on GitHub 1. Install Luminus +cljs First, setup a basic ClojureScript site using Luminus starter template from here lein new luminus cljs-angular2 +cljs This builds a great basic starter project with ClojureScript and figwheel already running.…
“Clojure is immutable, so you can’t change anything, how useless!” Immutable languages make application state an interesting concept. In Clojure, you can deal with application state in two main ways. The first way is to pass the state around as parameters to your functions. An example of Pass As Parameter: (defn delete! [db-con table id] (jdbc/delete! db-con table ['id=?' id]))…
A self-organizing team can be one of the most effective ways to build a team of high-quality professionals. What Is A Self-Organizing Team? I have managed several self-organizing teams over the last few years. They are expected to follow these tenets: The whole team organizes themselves to best meet the business needs Each team chooses their practices and working agreements All technical and…
“ActiveRecord is so hot right now!” - comment in 2006 Pop Culture Architecture is the current “fad” of the day. I have seen it be microservices, business capabilities, CQRS, service-oriented architecture, Domain-Driven Design, test driven development, ORMs, ActiveRecord, and MVC. Each of these have been fashionable at some point. Fashion is ultimately a signaling mechanism…
Please don’t hit me, Haskell does a great job of that already. I love Haskell for the same reasons I love Dark Souls. Fantastic and inscrutable lore, a great combat type system, a cliff-wall difficulty curve, and unending punishment. I want to collect some statistics from the GitHub API. Step One - Stack I download stack and start a project: > cd /home/jack/programming && stack new…
“We’ve never had a successful release” You just finished this really hard feature. The whole thing was worse than anyone realized. Not only that, but the feature wasn’t clearly explained, so you lost time churning on the actual requirements. Despite all the confusion, iteration, and technical challenges, you managed to get it working! You look back, savoring how much you…
After my post Interview Humiliation, a number of people have asked me how I interview compassionately. I strive to make my interviews as stress-free and respectful as possible while still rendering a yes/no at the end. Any good interview process needs to start with goals: Respect the candidate’s time Make the candidate comfortable Under-skilled candidates should feel no shame Both passing…
A couple years ago, a coworker told me a success story about mindful meditation. He explained how his wife took a class that required an hour of daily meditation for a whole month. He reported that she found it uncomfortable, but the effects were astounding. She claimed to feel more relaxed, more focused, and more “herself”. She found new reserves of motivation. She dropped the book…
(All these great ideas, but no one is listening? Check out my book: Convincing Coworkers) One day, I went into an interview, and I was humiliated. The Setup I used to think very highly of myself. This was early on in the Test Driven Development (TDD) craze, and I was one of the best I knew at it. I knew interfaces, classes, mocking frameworks, and best practices. I’d been taught all the…
If you are considering using F#, you might be curious how to handle unit test mocking, especially if you want to use both modules and classes. In a language like C# or Java, the common method is to a DI container or handmade constructor injection on a class. These “entry points” allow for a unit test to replace a real dependency with a test-only replacement. I previously posted an…
SimpleMock is a pattern for reducing TDD damage. You can use the pattern to organize your testing code without mocking or complicated dependency injection. SimpleMock works in any language with closures that can be passed around by reference, so off the top of my head: C#, Java, F#, Scala, PHP, C++, Ruby, and Python. I’m sure you can think of others. Example: Here is a brief (if a bit silly)…
I want to make a model that predicts bugs. I previously wrote a table for scoring language safety: Programming Language Safety Score, but it was extremely time consuming to score new languages or make modifications. Simplify, Simplify After being told I was overfitting the data, I’ve attempted to clean up by simply checking if each category is enforced, possible, or impossible. I score each…
Let’s play a thought exercise. Imagine your development toolchain is like a semantic version number. Small features that incrementally improve your situation are like minor updates. They don’t cause any large shifts in thinking or process. Major updates are big, new concepts, quantum jumps in theory or practice. I am not talking about the political, social, or financial aspects of a…
Several times in the last week people have lamented to me that they “just don’t get Lisp”. After hearing it for the third time, I thought back to my experience learning a Lisp. When I set out to learn a Lisp, I expected it would be easy. I figured, “I am pretty awesome at PHP, and have worked professionally in Perl, Python, and Java, this should be a cakewalk!”…
Learning new tools, technologies, and methodologies is hard. Counter-intuitively, the most exhausting part is after you’ve gained a good comprehension of the tool, and now, filled with excitement, you try to explain it to someone else. They almost always react with hostility. What is going on? You just took time to learn this exciting tool that could save everyone a lot of time, and not only…
Domain modeling in F# is significantly easier and safer than with the traditional .NET languages. This is because of the increased safety of pattern matching and the expressiveness of discriminated unions. These concepts are not in C# or VB.NET, and therefore bring a new tool to the table. To illustrate this, I found some old code I’d written to interact with a legacy system. The system uses…
I think the time has come for a standard programming language safety score. I want to use this model to help show that the concept of safety is much more nuanced than a binary bit of “has strong-static types”. When someone says “programming language safety”, it typically invokes thoughts of unit tests, long build times, and red squiggles in an IDE. But, in day-to-day…
Clojure is a delightful language, and here are six uncommonly discussed reasons why. 1 - Dead Simple Unit Test Mocking Clojure is the easiest language to unit test I have ever seen. “Mocking” a function in a test only requires a simple replacement of the function definition. No extraneous interfaces, no dependency injection, no mocking framework. The built-in function with-redefs will…
One of my favorite things about F# is how it lets you choose how you want to align your data. In the previous posts highlighting on pattern matching and inverted polymorphism we covered how pattern matching in F# is safer than if statements and can replace classes and interfaces for polymorphism. If you are unfamiliar with these concepts, you might want to skim those first. Today, for the 6th day…
I recently have been working in a Clojure project which is made up of several microservices. While trying to build in a secure method for each service to be able to call the others, I’ve been in several different projects at the same time. At least once I accidentally opened the wrong “handler.clj” buffer, and spent a few minutes adding a function that never worked. Since I hate…
(Want to become a Vim expert? Check out my new book: 10 Minute Vim) > Learning Vim is a waste of time; I can prove it! - Anonymous I recently had a gentle discussion with a new teammate about whether or not they should learn to use Vim. My team uses a Vim emulator inside Visual Studio and Emacs, and so we recommended he learn at least the basics so to reduce friction when pair-programming (which…
Edit: As a supplement to this: check out my favorite books. “It’s my first job, what book should I read first?” I’ve been asked this question many times. Even mid and senior level developers I’ve known sometimes struggle with this question. If you want to be truly great, you have to read technical books and white papers, and you have to learn new programming…
In my last post on the power of pattern matching, we saw how powerful the match statement is in F#. Using match allows the compiler to give us warnings for missing cases, no matter what the type. Let’s look at how pattern matching changes our design, allowing for an inversion of the usual OO way of polymorphism. Here is an example that is probably familiar to everyone: getting a database…
Pattern matching is a simple tool that will make your code safer and easier to read. Consider the following code that converts an Int to a string. public enum Language { Spanish, English } public static string convert(int number, Language lang) { string ret = ''; if (lang == Language.English) { switch(number) { case 0: ret = 'zero'; break; case 1: ret = 'one'; break; default: ret = '...'; break; }…
'... and it has to return 45,000 records a minute, or we are all screwed.' Monday morning, we inherited a legacy codebase. Tuesday, the word came down on stone tablets. Forty-five thousand records a minute, and no amount of political maneuvering or incremental gains were going to do. Too many broken promises. The last team mass quit over three months, leaving us the two most junior developers.…
Can we agree for this post that money, energy, time, and effort are all forms of power? Like literally, if I wanted to build a building, I am going to need tools, skills, materials, labor. I can use the most liquid form of power I have (cash) to acquire all these things, or I can use a much less liquid form of power (my time) to harvest, extract, refine, learn, and build my building myself.
Macros are the most powerful way to manipulate the syntax of your language. Macros make it possible to completely modify your language to match your domain. To explain them, think for a minute about functions using the simple “substitution model” used to teach functions to beginner programmers. The substitution model has the reader replace a function call with the body of the called function. def…
I was at the Clojadelphia meetup on Thursday, and got an excellent run through of the tools.trace library from Tim Visher. He has submitted a pull request to the original authors, with his expanded and very clear documentation found here. One call from the library in particular really stood out, a call for finding out what form threw an exception out of many. ;; trace-forms 'Trace all the forms in…