Week #6
Ok, this is not exactly refactoring and also I didn't finish it unfortunately. I was trying to do something with p5 for another class two weeks ago and couldn't get it to work smoothly enough. I don't know in what capacity I'll get back to it, but I think I know how to make it work better. The thing is the code is very messy, it has lots of stuff that aren't being used and I kind of lost track of how it operates. So I think this is a good opportunity to take all that gigantic mess and extract parts of it so I end up with a working sketch that does the basic thing I wanted to do — detect when the user's eyes are either open or closed (there are other components to this but this is the basic mechanic). The annoying part is — I definitely had a working version of exactly that! I worked in VSCode but didn't use git and... it's gone.
I created a new project, made sure to initiate a git repository and started going over the original code and copying any parts that contribute to the most basic tasks the code should start from. The problem is this code is already so intertwined with the server stuff it requires basically redoing half of it if not all. It's also using p5 in instancing mode because the original intention was to have many p5 canvases on the page, one for each user. I tried scaling down and just going through it step by step but had unresolved issues with the version of ml5's facemesh I was using (this was causing issues in the original code as well but eventually worked).
I'm sorry to say I don't have anything to share as I didn't get it to work just yet, it's just too big of a mess. What I should probably do is start this from scratch and "borrow" some functions I had in the original program and rewrite them to fit the new way things will be handled. I did find this attempt helpful in terms of practicing debugging and of course git which I'm definitely going to be using from now on! Sorry I don't have anything to share.