The second phase of coding ended last week. There isn’t much to say in this blog post, so I’ll just mention a few interesting things that I learnt in this phase:
QObjects are awesome!
One thing that I particularly dislike about C/C++ is that you have to free memory manually. And since I’ve been a fan of languages that support automatic garbage collection, I never really had to worry about that.
While working on my project, it completely slipped out of my mind that I would have to deallocate the memory too! However, my mentor Dongxu informed me that anything that derives from
QObject would automatically be destroyed when its parent is destroyed! And since almost all of the classes in my project derive from
QObject, I didn’t have to do anything about them. For those that didn’t, I switched to smart pointers instead of normal pointers.
m_ for members
I have seen the
m_ prefix being used for variable names at a lot of places. I never really understood the reason. I used to believe that perhaps it is another way of saying
my, as I had seen the use of the prefix
my in variable/class names too (
Initially, I didn’t use the
m_ prefix in my code. However, my mentor pointed out that Qt Coding Style mentions that Qt uses the
m_ prefix, and I’d have to update my code. It was really annoying TBH :p. Why would you unnecessarily add 2 extra characters to your variable names? There is some discussion about this ridiculous convention on a StackOverflow question.
Qt on Go!
I recently found out about this repo therecipe/qt which enables you to write Qt applications in Go! This is actually so cool! I’ve been programming in so many languages, but whenever I needed to build a GUI application, I always had to fall back to Java. The simplicity of the Java Swing Framework is unmatched, and I never tried to learn a GUI framework for any other language. With this, I can build GUI applications in Go, using Qt. Though it is still not as simple as Java Swing, it is worth trying out.
By the end of phase 2, I had an almost working project. I also showed a video recording of the project to the Org Admins. There is only one major feature left to implement, and then I’ll have to write the documentation. It has been fun so far!