Clojure Records and Protocols tutorial

preview_player
Показать описание
Clojure is all about maps! There are ways to make your data "more structured" without having to enforce type safety and that's by using records via the defrecord function.
You can also give records functions that use them via the defprotocol and extend-protocol functions :)

If you're wondering why you would use defrecord the reasons are faster key lookups and code legibility

0:00 Intro
0:11 Project setup
1:14 Defrecord
3:55 Defprotocol
6:45 Extend protocol
Рекомендации по теме
Комментарии
Автор

really helpful, from somebody who just started to learn clojure!

YihanPanFloria
Автор

Summarizing: defrecord is for adding properties using composition and defprotocol to add methods using composition! Damn! Every time I like Clojure ideas more !

LucasBatistussi
Автор

protocols are awesome for documenting boundaries functionalities that you need to test/modularize

viniciusataidedealbuquerqu
Автор

Keep them coming! Great job creating Clojure tutorials! Short and to the point.

romanostash
Автор

This video helped me so much. Thank you for making this!!

anomick
Автор

The funcool
/cats project uses protocols and records to implement CT stuff in Clojure at type level. They have great docs and some of the stuff pretty useful, for example, Exception monad for dealing with exceptions in more "civilized" manner

eugenej.
Автор

Is extend-protocol always necessary? extend-protocol seems to be confusing when implemented outside the defrecord form. What would be the problem while implementing the Display protocol in the Product defrecord like the following?

(defrecord Product [name]
Display
(title [this] (str "This product is a " name))
(description [this descr] (str "The " name " is " descr)))

mukundz
Автор

Nice video, thank you. But please, don't do these sensationalized thumbnails lol. You're not a kiddo YouTuber.

inanitas
welcome to shbcf.ru