Re:Clojure is Capable
by FPGAhacker on Friday December 28, 2018 @04:23AM
(#18775752)
Myself, I sort of do both bottom up and top down programming.
Usually I start at the top and write out high level code as if everything I needed magically existed. That helps me think about what I want and how I think I'll use it and that helps and clues me in to what low level stuff I need to build. Then I start to think about how to build those things and that usually goes bottom up.
I do this iteratively. When I get stuck I go back to high level top down, figure out what I'm missing, go build that, and repeat.
Re:Clojure is Capable
by AnimalMuppet on Friday December 28, 2018 @03:30PM
(#18779193)
That's called Ping-pong Design, and is a perfectly legitimate approach.
My approach to modularizing from the start is to do bottom up development, and to treat each namespace as a little library. Ultimately, pretty much all problems can be viewed as data transformation pipelines, and those naturally map to independent components doing different kinds of transformations. I find that the APIs tend to form naturally around domain boundaries as you move data from one context to another.
The REPL is indeed a major component of doing the Clojure workflow where you literally run each function as you're writing it. This approach also encourages refactoring as you go since you can make changes and see the results immediately.
I think the idea of bottom-up programming also resonates with me, though I tend to find it hard to use as a general approach to programming. In my mind, it's similar to the development of DSLs, which I do fairly infrequently, and with care. There is an undeniable elegance to it ... find a set of primitive operations that can be composed into larger ones. My development style usually goes in either direction: Either super generalized, for which I'll take the bottom-up DSL approach, or the more typical case where it's more approachable for me to be explicit with types/code.