The key to software is finding a great way to model the problem
In Clojure, the common advice is "just use a map". There's some truth to that, but it's obviously more complicated. Clojure gives you lots of ways to model a problem. You can use:
The truth is that choosing the right way to model the problem requires design decisions. Lots of tradeoffs. And lots of iteration. You might not get it right the first time. But you want to keep iterating until you get a tight fit between the structure of the problem and the structure of your code.
Each representation has limitations and tradeoffs. You want to find the limitations that help guide you to success and the tradeoffs you can live with. The hard truth is that it takes lots of experience to be able to do it quickly. But there's no magic to it.
Data Modeling in Clojure
In this course, I give you a peek behind the curtain. I work step-by-step through different iterations of a domain model, discussing what I'm thinking, why I'm trying something else. We model the game of solitaire, a card game we're all familiar with.
- How do you represent cards? The suit? The value?
- How to represent a deck of cards?
- What about the current state of a board?
- Can we represent a move?
This is a deep dive into the making of a domain representation. You'll be surprised how many options there are.
Data Modeling in Clojure
Want this course?
Love it or leave it guarantee
If you don't learn as much from this course as you thought, just ask for a refund within 30 days and I'll give you your money back.
This lesson introduces the Solitaire series. It goes over some of the basics of solitaire, the importance of becoming a domain expert, and how we can start to break down the domain into discreet concepts we can model. The lesson is 7 minutes long.
2. Card Representations
This lesson demonstrates and evaluates many different representations of playing cards. The lesson includes a video screencast, a git repository with all code, and some exercises. The video is 14 minutes long.
3. Card functional abstraction
This lesson teaches how to use functional abstraction to make changes to data structures quick and easy. This lesson includes a video screencast, a git repo, and two exercises. The video is 14 minutes long.
4. Modeling Games
This lesson teaches various options for representing the state of a game of solitare. It includes a video screencast, a git repo, and exercises. The video is 16 minutes long. The exercises might take 20-30 minutes.
5. Moves Part 1
In this lesson we test-drive a functional abstraction for representing moves in solitaire. We build two different moves and refactor them a little. This lesson includes a video screencast, a git repo, and exercises. The video is 11 minutes long. The exercises might take 20-30 minutes.
6. Moves Part 2
In this lesson we develop a new type of move and refactor all moves into a concise form. This lesson includes a video screencast, a git repo, and exercises. The video is 16 minutes long. The exercises might take 20-30 minutes.
7. Moves Part 3
In this lesson we develop a data representation for moves and a function to apply them to a game. This lesson includes a video screencast, a git repo, and an exercise. The video is 14 minutes long. The exercise might take 10 minutes.
8. Dealing a Game
In this lesson we develop a function that returns a new, dealt game. This lesson includes a video screencast and a git repo. The video is 16 minutes long.