Mozilla Development Strategies

  • Revision slug: Mozilla_Development_Strategies
  • Revision title: Mozilla Development Strategies
  • Revision id: 66652
  • Created:
  • Creator: Yoshino
  • Is current revision? No
  • Comment Migration (http://www.mozilla.org/hacking/development-strategies.html)

Revision Content

work on the most important bugs first

Everyone likes to check in. But keep in mind, checkin rate isn't everything. It's better to fix one dataloss bug, crasher, or performance bug that really affects the user than edge case bugs that are rarely seen or minor bugs.

take extra time to do it right the first time

It's also better to come up with one really solid, well tested, well commented, clean, easy to maintain piece of code than a bunch of quick fixes. You (or someone else) will be back in that code someday. It's easier to do it right once, when your mind is in the problem, then to do it once quickly and once again when you have to fix it The only thing worse that not understanding someone else's code is not understanding your own.

test your code

QA's job is to assure quality, not to add quality. That's your job. It's your responsibility to find the problems in your code before checking in, and to fix them. When you land your bug free code, it's QA's job to assure others that it's really bug free.

Make sure you appreciate anyone who finds a bug in your code. Appreciate it even more if they find it before you ship. They're giving you a second chance to get it right before it becomes a bug that affects users.

minimize how you are affected by regressions

Unless you are the type to go out and tackle daily regressions, you need to find a way to not let them affect you. You don't want to have one tree, update it every morning, and then be stuck waiting for blockers to clear.

Have multiple trees. At least one of them should be updated every day. You'll need this one for regressions that require your immediate attention (a new crasher, a blocker or regression that is in your area, etc.) Use this same tree for small, quick bugs or recent regressions or crashers. For your other tree, don't update as often. Update when you know that the tree is in good shape. Do your primary development in this tree. You'll need to update, rebuild, re-test and make a diff against the current trunk once you feel your fix is done. But, daily regressions won't block your primary development.

As far as keeping trees up to date - the longer you go without updating your tree, the more likely you are to have CVS conflicts. If you update every day for a week, you might not have any conflicts, but if you update once a week and you've changed a lot of code, you'll most likely have conflicts.

see mozilla\config\fast-update.pl for a fast way to update your tree - you can update your main mozilla tree (minus nsprpub, etc) in 1-2 minutes.

work on multiple bugs in parallel

You should be working on the most important bugs first. But those might be difficult bugs (hard to reproduce crashers, big rewrites for performance, etc.) which can take several days or weeks to complete, plus the time for reviews. In your other trees, work on smaller, easier bugs. Pick bugs that won't cause conflicts with your work in your primary tree. Pick bugs that should only take you a few hours or a day to fix. In theory, fixes for these bugs will be quick to review.

If you have problems finding smaller, easier bugs to work on, start by looking for crashers. Maybe the problem can be turned into an assert, or fixed altogether. You can use talkback queries or bugzilla queries to find crashers.

Also, look for mail window front-end bugs. We've got a lot of UI polish bugs that can be fixed with a small .dtd, .js, .properties or .xul change. In addition, look for problems in existing code. Find and fix string usage problems. Find and fix bad XPCOM macro usage. Switch some code over to nsCOMPtrs. Look for XXX or TODO in the code, verify the code still needs fixing, and fix it.

smaller patches get reviewed faster

If you find that you spend a lot of time waiting for reviews, keep in mind that patch size is not linear to time to review. A twenty line patch doesn't take twice as long to review as a ten line patch, it usually takes more time. If you can divide and conquer what you are working on into smaller chunks, you will find you'll get faster reviews. Of course, not everything can be divided up. And, shorter fixes aren't better than longer ones.

Having parallel trees should allow you to work on other items, while you are awaiting reviews.

get advice before working on a patch or feature before you start working on it, instead of after

If you are blocked, or stumped as to what to work on, talk to a lead sooner rather than later. Most likely they will have a bug they can hand off to you, or they can help get you unblocked. Since they are going to be reviewing your code later, run your plan of attack by them first. It's better to have an idea rejected, than a big patch.

if you are blocked, but have something worth checking in, check in using #ifdef, prefs, or "alternative" files

Sometimes you'll work on something, but you can't land it because something else is blocking you. You can still land (assuming you get reviews) if the code isn't on by default. This also makes it easier to get help on the problem. It's easier to tell someone set a pref, or apply a small patch, or set a #define then to apply a monster patch.

For C++, use #define, #ifdef, #else and #endif

For XUL / JS, and you're doing something major, add your new files to the tree and then have it be a simple jar.mn patch to enable it.

You can also have code that checked in, but controlled with a pref and off by default.

make sure you have the right fix (not a "I'll fix it later hack") when you go for reviews

When tempted to do a first pass fix and fix the fallout later, do it right the first time - don't assume you'll be able to file a "fix it" bug and fix stuff you know about later - chances are the reviewer will make you do the work anyway.

If it takes you five extra minutes to do something the "right" way rather than twenty minutes debating it with the reviewer - you've just saved yourself and the reviewer valuable time. Obviously, when doing it the "right" way means re-engineering large amounts of code, then incremental work is better - it's a fine line.

don't drag out reviews by fighting the reviewer in bugzilla (or email)

When getting a review, try not to belabor a point that a reviewer is debating you on. If the debate is involved, solve it in person, on IRC or over AIM. A five minute discussion is worth an hour of e-mails.

do thorough code reviews

When you review someone else's code, review thoroughly. If another engineer checks in code that causes regressions or introduces bugs, you might be the one who has to fix it later. Save yourself (and others) time later by doing a solid code review.

review your own code before you ask for reviews

Pratice your reviewing skills on your own patch before you seek reviews and a super review. Better that you catch something, than the reviewers or super reviewers. You might find a problem, or find that you left in some dump() or printf() statements, or have messed up the whitespace.

if you're working on something massive, start a branch

If you are working on something big, and you want to be able to check in incrementally without getting reviews, create a branch. But having a branch means dealing with conflicts when you land, and waiting a long time for reviews.

Here's how to create a branch:

from your linux box:

# start from your trunk tree on your local disk
cd mozilla
find . -type d \! -name CVS | xargs -l -P10 cvs tag -l MY_BASE_TAG > & ../taglog1.txt
find . -type d \! -name CVS | xargs -l -P10 cvs tag -b -l MY_BRANCH_TAG > &
../taglog2.txt

from your win32 box:

cvs co -r MY_BRANCH_TAG mozilla/client.mak
cd mozilla
edit client.mak, putting MY_BRANCH_TAG in the right places.
cvs commit client.mak
nmake -f client.mak

Original Document Information

  • Author(s): Seth Spitzer and Alec Flett
  • Last Updated Date: September 3, 2006
  • Copyright Information: Portions of this content are © 1998–2007 by individual mozilla.org contributors; content available under a Creative Commons license | Details.

Revision Source

<h3 name="work_on_the_most_important_bugs_first"> work on the most important bugs first </h3>
<p>Everyone likes to check in.  But keep in mind, checkin rate isn't everything. It's better to fix one dataloss bug, crasher, or performance bug that really affects the user than edge case bugs that are rarely seen or minor bugs.
</p>
<h3 name="take_extra_time_to_do_it_right_the_first_time"> take extra time to do it right the first time </h3>
<p>It's also better to come up with one really solid, well tested, well commented, clean, easy to maintain piece of code than a bunch of quick fixes.  You (or someone else) will be back in that code someday.  It's easier to do it right once, when your mind is in the problem, then to do it once quickly and once again when you have to fix it  The only thing worse that not understanding someone else's code is not understanding your own.
</p>
<h3 name="test_your_code"> test your code </h3>
<p>QA's job is to assure quality, not to add quality.  That's your job.  It's your responsibility to find the problems in your code before checking in, and to fix them. When you land your bug free code, it's QA's job to assure others that it's really bug free.
</p><p>Make sure you appreciate anyone who finds a bug in your code.  Appreciate it even more if they find it before you ship.  They're giving you a second chance to get it right before it becomes a bug that affects users.
</p>
<h3 name="minimize_how_you_are_affected_by_regressions"> minimize how you are affected by regressions </h3>
<p>Unless you are the type to go out and tackle daily regressions, you need to find a way to not let them affect you.   You don't want to have one tree, update it every morning, and then be stuck waiting for blockers to clear.
</p><p>Have multiple trees.  At least one of them should be updated every day.  You'll need this one for regressions that require your immediate attention (a new crasher, a blocker or regression that is in your area, etc.)  Use this same tree for small, quick bugs or recent regressions or crashers.   For your other tree, don't update as often.  Update when you know that the tree is in good shape.  Do your primary development in this tree.  You'll need to update, rebuild, re-test and make a diff against the current trunk once you feel your fix is done.  But, daily regressions won't block your primary development.
</p><p>As far as keeping trees up to date - the longer you go without updating your tree, the more likely you are to have CVS conflicts. If you update every day for a week, you might not have any conflicts, but if you update once a week and you've changed a lot of code, you'll most likely have conflicts.
</p><p>see mozilla\config\fast-update.pl for a fast way to update your tree - you can update your main mozilla tree (minus nsprpub, etc) in 1-2 minutes.
</p>
<h3 name="work_on_multiple_bugs_in_parallel"> work on multiple bugs in parallel </h3>
<p>You should be working on the most important bugs first.  But those might be difficult bugs (hard to reproduce crashers, big rewrites for performance, etc.) which can take several days or weeks to complete, plus the time for reviews.  In your other trees, work on smaller, easier bugs.  Pick bugs that won't cause conflicts with your work in your primary tree.  Pick bugs that should only take you a few hours or a day to fix.  In theory, fixes for these bugs will be quick to review.
</p><p>If you have problems finding smaller, easier bugs to work on, start by looking for crashers.  Maybe the problem can be turned into an assert, or fixed altogether.  You can use talkback queries or bugzilla queries to find crashers.
</p><p>Also, look for mail window front-end bugs.  We've got a lot of UI polish bugs that can be fixed with a small .dtd, .js, .properties or .xul change.  In addition, look for problems in existing code.  Find and fix string usage problems.  Find and fix bad XPCOM macro usage.  Switch some code over to nsCOMPtrs.  Look for XXX  or TODO in the code, verify the code still needs fixing, and fix it.
</p>
<h3 name="smaller_patches_get_reviewed_faster"> smaller patches get reviewed faster </h3>
<p>If you find that you spend a lot of time waiting for reviews, keep in mind that patch size is not linear to time to review.  A twenty line patch doesn't take twice as long to review as a ten line patch, it usually takes more time.  If you can divide and conquer what you are working on into smaller chunks, you will find you'll get faster reviews.  Of course, not everything can be divided up.  And, shorter fixes aren't better than longer ones.
</p><p>Having parallel trees should allow you to work on other items, while you are awaiting reviews.
</p>
<h3 name="get_advice_before_working_on_a_patch_or_feature_before_you_start_working_on_it.2C_instead_of_after">  get advice before working on a patch or feature before you start working on it, instead of after </h3>
<p>If you are blocked, or stumped as to what to work on, talk to a lead sooner rather than later.   Most likely they will have a bug they can hand off to you, or they can help get you unblocked.  Since they are going to be reviewing your code later, run your plan of attack by them first.  It's better to have an idea rejected, than a big patch.
</p>
<h3 name="if_you_are_blocked.2C_but_have_something_worth_checking_in.2C_check_in_using_.23ifdef.2C_prefs.2C_or_.22alternative.22_files"> if you are blocked, but have something worth checking in, check in using #ifdef, prefs, or "alternative" files </h3>
<p>Sometimes you'll work on something, but you can't land it because something else is blocking you.  You can still land (assuming you get reviews) if the code isn't on by default.  This also makes it easier to get help on the problem.  It's easier to tell someone set a pref, or apply a small patch, or set a #define then to apply a monster patch.
</p><p>For C++, use #define, #ifdef, #else and #endif
</p><p>For XUL / JS, and you're doing something major, add your new files to the tree and then have it be a simple jar.mn patch to enable it.
</p><p>You can also have code that checked in, but controlled with a pref and off by default.
</p>
<h3 name="make_sure_you_have_the_right_fix_.28not_a_.22I.27ll_fix_it_later_hack.22.29_when_you_go_for_reviews"> make sure you have the right fix (not a "I'll fix it later hack") when you go for reviews </h3>
<p>When tempted to do a first pass fix and fix the fallout later, do it right the first time - don't assume you'll be able to file a "fix it" bug and fix stuff you know about later - chances are the reviewer will make you do the work anyway.
</p><p>If it takes you five extra minutes to do something the "right" way rather than twenty minutes debating it with the reviewer - you've just saved yourself and the reviewer valuable time.  Obviously, when doing it the "right" way means re-engineering large amounts of code, then incremental work is better - it's a fine line.
</p>
<h3 name="don.27t_drag_out_reviews_by_fighting_the_reviewer_in_bugzilla_.28or_email.29"> don't drag out reviews by fighting the reviewer in bugzilla (or email) </h3>
<p>When getting a review, try not to belabor a point that a reviewer is debating you on. If the debate is involved, solve it in person, on IRC or over AIM.  A five minute discussion is worth an hour of e-mails.
</p>
<h3 name="do_thorough_code_reviews"> do thorough code reviews </h3>
<p>When you review someone else's code, review thoroughly.  If another engineer checks in code that causes regressions or introduces bugs, you might be the one who has to fix it later.  Save yourself (and others) time later by doing a solid code review.
</p>
<h3 name="review_your_own_code_before_you_ask_for_reviews"> review your own code before you ask for reviews </h3>
<p>Pratice your reviewing skills on your own patch before you seek reviews and a super review.  Better that you catch something, than the reviewers or super reviewers. You might find a problem, or find that you left in some dump() or printf() statements, or have messed up the whitespace.
</p>
<h3 name="if_you.27re_working_on_something_massive.2C_start_a_branch"> if you're working on something massive, start a branch </h3>
<p>If you are working on something big, and you want to be able to check in incrementally without getting reviews, create a branch.  But having a branch means dealing with conflicts when you land, and waiting a long time for reviews.
</p><p>Here's how to create a branch:
</p><p>from your linux box:
</p>
<pre># start from your trunk tree on your local disk
cd mozilla
find . -type d \! -name CVS | xargs -l -P10 cvs tag -l MY_BASE_TAG &gt; &amp; ../taglog1.txt
find . -type d \! -name CVS | xargs -l -P10 cvs tag -b -l MY_BRANCH_TAG &gt; &amp;
../taglog2.txt
</pre>
<p>from your win32 box:
</p>
<pre>cvs co -r MY_BRANCH_TAG mozilla/client.mak
cd mozilla
edit client.mak, putting MY_BRANCH_TAG in the right places.
cvs commit client.mak
nmake -f client.mak
</pre>
<div class="originaldocinfo">
<h2 name="Original_Document_Information"> Original Document Information </h2>
<ul><li> Author(s): <a class="external" href="mailto:sspitzer%40mozilla.org">Seth Spitzer</a> and <a class="external" href="mailto:alecf%40netscape.com">Alec Flett</a>
</li><li> Last Updated Date: September 3, 2006
</li><li> Copyright Information: Portions of this content are © 1998–2007 by individual mozilla.org contributors; content available under a Creative Commons license | <a class="external" href="http://www.mozilla.org/foundation/licensing/website-content.html">Details</a>.
</li></ul>
</div>
Revert to this revision