# Deliberate Practice #12 2022-07-14

This is a series where I write lesson(s) learned during the day, so that I remember them better. Hopefully you take away something too!

# Computer Science

I'm only on page ~272, and this book continues to shake my world! Almost feel cheated for not starting with this book in my computer science introduction haha

Anyway, I'm currently in the section called "Data directed programming" about how one can abstract the process of adding more representations for an abstract data type. The book uses the example of complex numbers, but I'll use the example of a point in 3D space.

The 3 classical representations of a point you are introduced to in multivariable calculus is with 3 rectangular coordinates (x,y,z), spherical coordinates (r, theta, phi), or cylindrical coordinates (r, theta, z). Now, there are pros and cons amongst them, but we want our functions that take in 3D points agnostic to the representation. Say we have a function `getDistanceFromOrigin(pt)`. Instead of hard-coding in the different cases of what to do with the representations, we give it an internal lookup table of functions, and allow library creators to then add to that table, so that no matter what wacky idea you have for how to represent 3D coordinates it can be done.

A use case that comes to mind would be if your program is working with 4D coordinates for some reason, and you have to drop down to 3D for a little bit, but you don't want to just lose that 4th dimension of information. So you create a suite selectors and functions that allow you to that info, and at the end cast your data type back out.

This felt a lot like learning about OCaml's match construct that allows you to take differing operations, but the twist was that your match does not have to even know about all the possible representations available since it does a lookup on a table which then instructs it how to handle the data, which allows for greater extension in the future.

# Productivity

I want to reward myself for being consistent about working, but currently my time targets are only split up into biweeks, so making a mistake has different effects depending on if its at the beginning or end of a biweek cycle. If it's at the beginning, it ruins any motivation to keep going, but if it's at the end then it feels like wasted effort. By making my biweek targets continuous in the Excel formula, so every day has a summary of the past 14 days performance, I think I can get a more accurate formula, as well as get back to guilt-free enjoyment of all the lovely media I like so much.