Ulises Alexander Arguelles Monjaraz
Ulises Alexander AM

Follow

Ulises Alexander AM

Follow
The book library

The book library

Code organization

Ulises Alexander Arguelles Monjaraz's photo
Ulises Alexander Arguelles Monjaraz
·Oct 28, 2022·

2 min read

Play this article

Table of contents

  • How it is now
  • The base of the new way
  • How it would be

This little post would be about how I had, and I'm planning to organize the code inside my book library. This library is part of the reading management system that I'm working on. But, at the moment, this is where I'm focusing my efforts.

How it is now

Originally, I did'n have a structured way to organize the code of my library. Currently, my code is organized like this:

  1. Type Classes
  2. Type declarations and newtype declarations with their functions next to them.
  3. Sum data type definitions.

the-book-library--code-organization--1.png

The base of the new way

Now, I'm planning to implement the following approach, described by Eric Normand :

  • Actions: Anything that depends on when it is run, or how many times it is run, or both [...].
  • Calculations: Computations from input to output. They always give the same output when you give the same input. [...].
  • Data: Recorded facts about events. [...]. [1, p10]

How it would be

How this would look without seeing the actual code:

  • First I would put the data or in this case what is a book. Type classes, type and newtype declarations; type aliases, and data types.
  • Then the calculations in this case and by the moment the functions to wrap and unwrap around my defined types, and other operations that don't need to interact with the outside world.
  • Finally, I would put the actions, right now the only type of functions that I think could go here are time-related functions.

the-book-library--code-organization--2.png

References

[1] E. Normand, Grokking simplicity: taming complex software with functional thinking. Shelter Island, NY: Manning Publications Company, 2021.

 
Share this