Fork me on GitHub
#code-reviews
<
2021-01-09
>
Idan Melamed10:01:09

https://github.com/idanmel/tic-tac-clojure/ After a couple of years of trying to stick with learning Clojure, I created a tic-tac-toe "game engine". Any feedback would be appreciated. 🙂

enforser16:01:54

One thing I noticed is that your docstrings should be before the function parameters. Anything after the function parameters is evaluated, so each function is actually initializing the string the immediately forgetting about it

thanks3 3
👍 3
enforser16:01:32

in draw-status you can use when instead of if

enforser16:01:16

A style I prefer is to destructure right in the parameters.. i.e. instead of

(defn f [foo]
  (let [{:keys [a b]} foo] ...))
you could just do:
(defn f [{:keys [a b]}] ...)

jaihindhreddy13:01:48

Instead of This is the only function that should be used from outside this namespace..., you can use defn- to make fns private to the namespace.

pavlosmelissinos21:01:59

Also even though this is a pretty contained project and you don't have a lot to gain, on top of replacing most defns with defn- (or instead of it) you can have a separate api namespace just for symbols that are meant to be exposed to the world

pavlosmelissinos21:01:29

I'd also add some specs and try to use them to validate the user's input (e.g. move) to find out if/how I could "reduce" the boilerplate in the turn function