Thursday 27 June 2013

Week 1

For my first week of the GSoC coding period, I focused on designing the models of my application. A Model, as it is known in Django terminology is the Schema. Designing the schema is an important first step towards building the API. The Mailman core exposes information about the Lists, Domains, Users, List Members etc, but these things are not properly related to each other well enough. So I went on about making connections between the various entities in the system using these models.

Basic models for Domain, MailingList, List Settings, and something called a "Subscriber" though we won't be sticking to that name for long, are good enough for now. I also managed to hook a few of these new models into the existing Postorius application. Not surprisingly, had to change a few things up a little to make them work properly, but I want to make as few changes as possible in the Postorius codebase.

I started writing tests for these models as well! That was my favorite part of the entire week. Writing tests is a lot of fun! There's a sense of satisfaction that you get when you see all those tests passing without a hitch. I loved it, and am finally beginning to understand why some programmers are obsessed with TDD (Test Driven Development).

Apart from writing tests, something else that I've started to look into is Schema migrations in Django using South. As my schema changed, I always had to test the new one out, and re-creating and syncing the database manually is one of those annoying things that I shouldn't have wasted much time on, as I now realize. South takes care of everything by allowing a Django database to be migrated from one state to another as your models are updated. You can also move forward and backwards from one state to another easily, allowing you to keep track of all the changes in the schema. It is somewhat anologous to Git, I think.

Speaking of Git, another thing that I learned (or re-learned, as I had known it before but just never got in the habit of using it that often) is git's patch mode! This is an excellent tool to selectively add and commit things inside a large diff, so that all your commits have a single focus and no unrelated changes go inside that commit. This is done to ensure that we have a proper record of changes that we may later want to look at, or ease the process of reverting git history, which will be quite confusing if reverting one commit not only reverses the change that you want, but also the unrelated changes that were recorded in that commit. Anyway, patch mode is quite awesome, and you can find a great explanation (with videos!) by John Kary here.

If I'm being honest with myself, I must admit that this week turned out to be slow going. A couple of times, I got bogged down into the details and failed to see the big picture, which led me to waste time on bugs which could have easily been resolved. I should also have been writing tests much earlier than I actually did, which led to me wasting some time testing things out manually in the Django shell, every time I made changes in the schema.

Hopefully, I will be much more productive in the upcoming weeks.

Now some non-code news. I've started working out of the new office of the company that I interned for last  year, SD. SD's new office is an awesome place to focus solely on the work without the distractions of working out from home. :)

And finally, my welcome package arrived, which, apart from the Visa cash card, also contained some goodies like a Diary, a Pen, and an awesome Sticker. Thanks, Google!

That's it for now. Until next week.



Tuesday 18 June 2013

The adventure begins!

Yesterday was my last exam. As of today, I no longer have to worry about any upcoming exam or any other college-related thing like assignment, and can completely focus on GSoC. :-)

This past week, my mentor, Richard has been helping me get completely set up with the new layout for the project. The setup included an initializing script, "bootstrap.sh", which wasn't quite doing what we expected it to do, (partially due to my derping and using zsh instead of bash), and we spent quite a lot of time debugging.

Anyway, for the upcoming weeks, I'll be focusing the applications's Models. So I spent the day reading the documentation for Django models, managers, and the code for how the custom User model works in  django.contrib.auth.models. We will be working towards making extensible models, whose functionality can later be improved by plugging in "mixins".  Mixins are a topic that I haven't studied deeply. I think I wrote a few mixins as part of a Coursera class last year in Ruby, but that was quite a while ago. So I'll be spending some time studying the Mix-in pattern, specifically for Python, and work out how I can use that in my models.

I will then look into DRF (Django Rest Framework) and work on exposing these models via a REST interface.

That's it for now. Until next time!