<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sealyu

    --- 博客已遷移至: http://www.sealyu.com/blog

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

    Versioning systems like CVS, SVN or Darcs are very important tools, that no serious programmers can omit to use. If you started a project without using any versioning tools, I really recommend that you start using one immediately; but I’m not discussing this right now.

    I would like to point your attention to some best practices that I recommend when working in a team.

    1. Don’t use versioning like it were a backup tool.

      I’ve heard this question too often: “Have you put your code safely on SVN?”. That’s a bad question. Storing code to an SVN server is not meant for safety, i.e. for fear of losing it. You are talking about something else, and that’s called backup. Take Darcs, a not so popular versioning system. It can start without a server, and you can just run it locally on your machine without launching any daemon whatsoever. A faulty hard drive can still make you lose all your work, of course. That’s why you have to do backups, of course, but they don’t have anything to do with versioning. Hence, committing to the repository once a day, before taking off home, e.g., is not an acceptable practice, especially if you work in a team. Doing that would be like making a daily backup. An SVN commit, instead, has to have a meaning of some sort, not just “Ok, let’s store to the SVN server the work of today”. Moreover, sometimes, if the schedule is tough and the cooperation is tight, you need to commit very often so your peer will keep up with you all the time, and not just find out, at evening, that he’s got dozens conflicts after checking out your code.

    2. Commit as soon as your changes makes a logical unit.

      How often should you commit? Theres no such thing as committing too often, or too rarely. You should commit each time your changes represent a logical unit, i.e. something that makes sense. Usually that happens because you’re following a plan, when coding (because you are, aren’t you?). So, you find out a bug in the trunk, plan a strategy about how to fix it, fix it, and then commit. This makes sense because that’s a commit that fixes a bug. So that revision X is buggy, while revision X+1 is not. Don’t be shy about committing too often. Should you just find an insignificant typo in a debug string, or in a comment, don’t be afraid of committing just to fix that. Nobody will be mad at you for being precise. Consider the extreme situation in which, after months and months, you may want to remember “What was the revision where I fixed that typo in that debug string?”. If you dedicated one signle commit for the actual finite logical unit of correcting the typo, you can just scroll back your changelog and find it. But what often happens, is that people will be doing something else, and, while doing that something else, will notice the type, and correct it, and basically merge that correction with the rest of the commit, making that thing losing visibility. To make it simple: your SVN comments shouldn’t explain that you did more than one thing. If your SVN comment looks like “Fixing bugs #1234 and #1235″ or “Fixing bug #4321 and correcting typo in debug sting” then you should’ve used two commits.

    3. Be precise and exhaustive in your commit comments.

      The second most annoying thing ever is committing with blank comments. If you’re working in a team, your peer developers will be frustrated about it and possibly mad at you, or will label you in a bad way; possibly publicly humiliate you. If you’re working alone, you will experience what you’re hypothetical development companions would have: frustration in not being able to easily track down what a certain commit did. Comments in commits are important. Please be precise and explain in detail everything you did. In the optimal case, I shouldn’t need to read your code.

    4. Never ever break the trunk.

      This is probably the most annoying thing when dealing with people who can’t use versioning. Breaking the trunk is an habit that will quickly earn you the hatred of your colleagues. Think about it: if you commit a patch that breaks the trunk, and then I check it out, what am I going to do? The project won’t build so I either have to fix it, or come to your desk and complain to you. In both cases I’m wasting some time. And consider the first case again: what should I do after fixing your broken code? Commit it? Sending you a diff? If I’ll commit, chances are that you’ll have conflicts when you checkout, and you’ll have to waste time in resolving them. Maybe sending you a patch would be the best way, but still it’s a waste of time for the both of us. So the thing is: before committing, ALWAYS double check! Make a clean build and make sure that it builds. And don’t forget to add files! It’s a very common mistake: committing good code, but forgetting to add a file. You won’t realize, because the thing builds, but when I’ll checkout, I’ll have troubles, because of missing file(s). If you’re using Darcs, just make a “darcs get” in a new directory, and then build.

    5. Branch only if needed.

      There are some ways to handle branches, but here’s my favorite. The most of the work should happen in the trunk, which is always sane, as stated by the previous practice, and the patches should always be small, so that they can be reviewed very easily. If you find yourself in the situation of needing to write a large patch, then you should branch it. In that way you can have small patches that will break your branch over the time, but they can be easily reviewed. After the process is completed, i.e. you’ve achieved your goal of fixing a bug or implementing a new feature, you can test the branch thoroughly, and then merge it to the trunk.

    posted on 2009-09-02 21:47 seal 閱讀(808) 評論(2)  編輯  收藏 所屬分類: 版本控制

    評論

    # re: 五個使用SVN的好習(xí)慣(5 SVN best practices) 2010-06-18 11:27 lacewigs
    呵呵樓主寫的很好啊。  回復(fù)  更多評論
      

    # re: 五個使用SVN的好習(xí)慣(5 SVN best practices) 2014-04-25 16:33 ee
    如果是中文的我覺得會更好的  回復(fù)  更多評論
      

    主站蜘蛛池模板: 免费无码AV电影在线观看| 免费国产a理论片| 中文字幕亚洲免费无线观看日本 | 免费人成网上在线观看| 国产精品亚洲五月天高清| 亚洲精品无码久久久久A片苍井空| 亚洲国产美女在线观看 | 亚洲一区二区三区在线视频| 久久不见久久见免费影院| 人妻无码久久一区二区三区免费| 中文字幕在线观看免费| 一个人晚上在线观看的免费视频| 国产亚洲蜜芽精品久久| 亚洲黄色高清视频| 97亚洲熟妇自偷自拍另类图片| 亚洲色婷婷综合久久| 在线观看国产区亚洲一区成人| 亚洲AV成人精品日韩一区18p| 国产精品酒店视频免费看| 永久免费bbbbbb视频| 免费91最新地址永久入口 | 日本一道高清不卡免费| 黄页网站在线观看免费高清| 日本免费在线观看| 亚洲精品在线免费观看视频 | 亚洲中文字幕一二三四区苍井空| 亚洲熟妇自偷自拍另欧美| 在线a亚洲老鸭窝天堂av高清| 亚洲欧洲精品成人久久曰| 亚洲一区精品中文字幕| 亚洲av午夜成人片精品电影 | 老外毛片免费视频播放| 免费无码AV一区二区| 国产一级黄片儿免费看| 久久香蕉国产线看免费| 久久这里只精品热免费99| 中文字幕免费播放| 暖暖在线视频免费视频| 久久精品国产免费观看| 免费黄色福利视频| 亚洲AV无码乱码精品国产|