开发者

Program development

开发者 https://www.devze.com 2023-01-19 17:13 出处:网络
I am writing a C program. What I have seen from my earlier experiences is that I make some changes on a correct version of my program, and after that change, the program is computing incorrectly.开发者

I am writing a C program. What I have seen from my earlier experiences is that I make some changes on a correct version of my program, and after that change, the program is computing incorrectly.

开发者_如何学Python

Now, for one occasion it may be easy to detect where I made that change and undo it or do it in some other way, and for other occasions I find it hard (with labor) to detect where exactly the problem is.

Can you suggest some platform or tool which allows you to put the new version and old version of the program side by side and mark the changes that were employed on the new version.

I am using gcc 4.3.2 to compile c programs on Ubuntu 10.04 OS.

Any suggestion is welcome.

regards, Anup


Use a version control system. I recommend Subversion. This will allow you to compare your newer version with the older one to see exactly what changed and you can revert to the older working version if you break your code.


If you want a tiny, small, portable, one-file personal control version system, I can suggest fossil. A documentation is available here.


What you are requesting is some diff-like tool. There is a plethora of such tools, ranging from the diff command line utility to GUI frontend such as http://meld.sourceforge.net/. Most of these tools can be combined with (or have counterparts in) revision control systems as Subversion.


I would do this with some version control system, like Git. Refer to Git for beginners: The definitive practical guide if you're new to version control systems and/or git.


Thats the main purpose of all the version control management software. I recommand to look at Subversion, GIT or Mercurial.

There are thousands of internet resources for this programs.

And they all have good comparision programs integrated in their GUI Tools.


Also, try to use Git/Mercurial/whatever together with Dropbox, it will allow you to continue developing on other computers. It will also teach you how to collaborate with others and with yourself.

This is slightly easier to do with the newer VCS systems like Git and Mercurial.


If you would use a version control system, such as Git or Mercurial, and follow a few good practices:

  • committing small, self contained changes (which includes committing, i.e. saving changes to version control, often)
  • committing known good state (or at least trying to, e.g. ensuring that code compiles before you commit)

you would be always able to go back to known good state.

If bug is/was in your current changes, you can compare current state with previous version: somewhere in changed lines there is bug... or something in changed lines uncovered an existing bug.

If bug was introduced by some earlied, unknknown commit, you can use bisect to search through history to find first commit that exhibits given bug: see for example git bisect manpage.

HTH

0

精彩评论

暂无评论...
验证码 换一张
取 消