Fork me on GitHub
#code-reviews
<
2020-11-24
>
fullNameHere05:11:12

Made this little throwaway project. Was wondering if anything could be made better? More concise? https://github.com/SantoHerrera/clojureCalendar Thanks in advance!

phronmophobic05:11:25

a few suggestions: • if you're only getting and updating one level deep, you can replace get-in with get and update-in with update and changing the path to just be the key • update calendar does nothing if the provided date isn't found in the calendar. this should be an error and shouldn't be silently ignored • into accepts a transducer. I'm not sure it's better, but booked-events could be written as:

(defn booked-events
  [calendar]
  (into (sorted-map)
        (filter
         (fn [x]
           (get-in x [1 :booked?])))
         calendar))
• for get-next-x-days, the other variable could probably be better named • create-data would be more clear if named something like init-calendargenerate-string doesn't seem to exist? • generally, I would structure it so that a function like get-input would only ever run one iteration and some calling function would handle the looping. ie. separate the step from the loop. • I think read-calendar-input or something like that would be clearer than get-input • generally, :refer :all should be avoided

👍 1
phronmophobic05:11:08

I might also consider a design where the calendar didn't need to be pre-populated. ie. missing dates were assumed to be unbooked