Archive for the ‘code hunting’ Category

Today was the first class of my BTP600 Design Patterns class. The teacher talked about how there are 3 ways to go about learning to write larger, non-trivial programs.

  1. Try + Fail + Fix
  2. Read the code of other (superstar) coders to see how they did it well
  3. Design Patterns

I like this class. It’s very hard to see how I will ever write something large and non-trivial but I know that’s what we will accomplish by the end of BTS and this course as well. When I look at the mozilla code base, I can’t see how something like this came to be. What do you write first?

The teacher mentioned that Kernighan (sp?) and Richie write really great code and so I’d like to read some. Anyone know of a good example? I welcome tips on code that you may have found exciting to read.


Read Full Post »

Well. I am jazzed up while I sit in BTB right now because I MADE A PATCH!

Yessir. The lab for today’s class asked us to try and modify our browsers so that opening a new tab makes it appear to the right of the current tab, instead of the way it currently opens the new tab at the far right end of all tabs.

We all jumped on to MXR and … it froze. So for a bit, I stared at the screen and wondered – “How hard is this going to be?”.

Well, not too bad actually. I searched for “New Tab” and found /browser/base/content/tabbrowser.xml which has a comment:

// We’re adding a new tab here.

Looks like I’m in the right place.

Turns out tabbrowser.xml is the best place to go because that’s where my changes will be made and it also happens to be where all the methods regarding tabs are located.

Now I’m staring at some javascript. Immediate guilt sets in for not being more competent in this language. When did we take javascript? Back in third term. It’s now buried beneath a tiny bit of perl, a pinch of php and attempts at ruby.

loadOneTab() is called when a new tab is added, loadOneTab() calls on addTab(). These are all in the same file. I’m focusing on addTab(). This is my target for adding some lines.

addTab() creates a tab object with the variable name t and then appendChild(t) to mTabContainer. Let’s look at mTabContainer…

What do you know – it has a method called moveTabTo(). Cool, that’s what I want to do. I want to moveTabTo() the index next to the one that’s calling the addTab().

See tabPatch to get the rest of the story I’ve got to go do a victory lap.

Read Full Post »