OOP Blog Post #3
What did you do this past week?
I did a bunch of homework as well as grade test cases for CS439. Someone made a test case using the Collatz conjecture, so that was pretty cool. Speaking of which, I finished the Collatz project today as well.
What’s in your way?
I tend to procrastinate on things I don’t really enjoy, and while I’m enjoying most of the classes I have this semester, there’s always that non-CS general education requirement that, while interesting, I’d prefer not to take. So the work for that tends to take the most time since I keep putting it off to work on funner things.
What will you do next week?
Pretty much the same thing I did this week. If I have time, though, I would like to work on some personal projects and apply for internships.
If you read it, what did you think of the Continuous Integration?
It was an informative read; I’m considering setting up CI for some of my personal projects (e.g. the lambda calculus interpreter I haven’t worked on since last week). Since I’m not used to writing unit tests and continually testing my code, it’ll hopefully force me to get into the habit of doing this and make me more productive.
What was your experience of Collatz?
It took longer than necessary because I was messing around with fun, premature, and unnecessary optimizations. Also because I encountered a bug that took me way too long to find — I thought something was wrong with my cycle length function when it turns out I’d simply swapped the inputs and was failing tests where the first number was larger than the second. A large chunk of time was also spent figuring out the workflow — adding issues, merging, generating documentation, etc.. It was a good introduction to these software engineering concepts, even if the underlying project itself was relatively simple.
What was your experience of exceptions?
I’ve encountered and used exceptions sparingly. It seems like exceptions are good for handling errors that may occur during runtime that aren’t necessarily the result of buggy code, such as rare circumstances or user error. I haven’t really needed to use exceptions so far, but I’m expecting upcoming projects in the class to give me the opportunity to try them out.
What made you happy this week?
Lots of students came to office hours this week! As expected, a challenging project is the easiest way to to get students to come.
What’s your pick-of-the-week or tip-of-the-week?
While I don’t believe doing this is necessary for the Collatz project, a fun idea to optimize caching of values is to cache only even or odd numbers. It’s very easy get from an odd number to and even one in the cycle (or vice versa) by definition. (Getting from an even number to an odd one in constant time is a bit harder, but functions like __builtin_ctz
provided by gcc are very helpful in this regard.) At least in theory, you can then half the size of your cache without any significant performance decrease.