I saw a lot of presentations at Clojure/conj 2015. Most of them were really great, but one of them I was particularly interested in seeing didn’t really do it for me. It was called Bottom Up vs Top Down Design in Clojure by Mark Bastian. I thought his presentation was interesting, but it failed to touch on a couple of points that I was interested in. In an effort to learn a bit, I figured I would write post about what I was hoping the talk would actually address.
My personal experience has been that working from the top down leads to best API design. I also find that it makes it easier for writing well tested object oriented code. That’s because you can pretty easily know when you are going to have dependent behavior and mock that out on the layer below whatever you are writing. This helps to identify and segregate the dependencies early. Something that doesn’t always happen when you are coming from the bottom up. What I find often happens when I’m designing from the bottom up is that I don’t realize I need to split a class until after I have started using it in the layer above. That said when you are writing properly functional code without side effects collaboration often looks somewhat different then when you are writing collaborating object.
What I wish I had seen
All programming I’ve ever done in Clojure has been of the first kind. I’ve found it easier to build up more complex functions from simpler functions. I was hoping that someone with more experience would show what outside in design of software would look like in Clojure. So I think I’m going to have a multi part post about building a tic-tac-toe game in Clojure in two different ways. First from the bottom up and second from the top down. I’m also using a TDD only approach to the project. I’ll try and keep the commits relatively clean and done after each test. You can see the code here.
I think it will be interesting and instructive to compare the two different code bases after I have them written.