TDD TTT

TDD + TTT = Profit?

Taking the lessons I have learned from Gina this past Thursday and Friday I am implementing TDD while developing the TTT program. There has been a learning curve to applying TDD faithfully and utilizing it in such a way that it does not hinder your progress but it enhances the quality of the prod code & grants you a clear direction of what should be next in terms of what the next prod code/test. With that being said here are some of the things I have picked up from working on TTT using TDD:

Challenges

  • Figuring out the first test case to write for creating the TTT application (TDD approach)
  • Figuring out whether board should be an array of char or strings
    • e.g. [\X \O …] 
    • e.g. [“X” “O” …]
  • What to test nextafter testing for a tie game ==> Check for WIN
  • In what order should I write the test cases & should I be initially checking for wins (true) or all the false cases first
  • Do I need to make another class/file for the console?
  • What should the initial board state be:
    • Completely empty []
    • Vector full of blanks, e.g. [\u0020 \u0020 \u0020 \u0020 \u0020 \u0020 \u0020 \u0020 \u0020]
  • Refactor win? into helper funcs (do that as soon as all the tests are passig –> green refacotring) or work on a diff part of TTT & come back later to refactor
    • Is something like this based on a case by case basis or should you prescribe to one school of thought?

TIL

  • obvious but string in Clojure can be viewed as a sequence of characters
  • strings are objects as opposed to sequences? (Interesting…are most data types in Clojure sequences then?) 
    • char is a primitive data type
    • String is a class in Java
  • Clojure’s string and char are based on java.lang.String and  java.lang.Char
  • When to use char vs. string:
    • In terms of performance char takes up less memory for times when you only need one character 
    • Also, since String is an object –> it comes at a greater overhead 
    • Primitive types in Java (Clojure as well…) have an advantages in terms of speed and memory footprint
  • \u0020 = blank space
  • Start with all the false cases (idea is that the prod code is general but the test cases can be specific - throwback to the inverse relationship btwn. prod code & testing

Joplin

I have recently been using Joplin for my note taking - especially when I am working on a user story. The idea is that I work on a user story for about 30~60mins and then I take about a 5-10mins break where I open up my note in Joplin and write down a challenge, TIL, etc. that I encountered while working on the user story. This process is repeated until the task at hand is complete. Anyways, all of this is done with the intent of keeping track of how I am making progress through the user story && most importantly Joplin has an option to view your notes in markdown format so when I am ready to write my blog I execute my series of complicated command shortcuts: cmd + c cmd + v and just like that I am mostly done writing a majority of my blog. Just gotta add a nice opening and closing section, just like what I am doing right now haha.

Written on June 7, 2021