Sign in to follow this  

Maintaining a code library

This topic is 1467 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm learning c++ I thought that if I have a peice of code that I made or found and I think it may be useful at a later date how do I keep them?

What I mean by keep them is how do I maintain my own code library in order to keep them organised?

Is it a folder on my drive?
Is it a document with them all in?

What's your way?

Share this post


Link to post
Share on other sites

What you're looking for is a topic called "Revision Control."  At the moment, your best solution is to try Git.

 

http://git-scm.com/

 

The simplest thing to do is to setup a repo and put it on Google drive or drop box or something.  That way you can access the code from home, school, on vacation, and you have an offsite backup.  Of course putting your stuff online caries some risk of someone else stealing your code, but if you're just learning to code, that's not a concern.

 

I wish I had know about revision control when I was in school.  One of the great things these systems do is keep track of changes and let you undo mistakes.  This would have saved me countless hours in school when I broke something and couldn't get it working again.

 

Work through the manual, and just learn the command line.  There are only a few commands that you'll use on a daily basis anyway.

 

http://git-scm.com/book/en/Getting-Started

 

For example, all I ever use is:

 

git checkout -b new-branch 

git add --all

git commit -am 'commit message'

git stash

git stash pop

git merge --no-ff branch

git branch -d to-delete

 

And that list is for a company with tons of software.  You won't event need all that!

Share this post


Link to post
Share on other sites

I think that Mercurial should be mentioned too. You can read all about it here.

 

Both work on the same principle, but Mercurial (or simply hg) is considered more newbie friendly then Git. It has simpler interface with fewer options that "do the right thing".

Share this post


Link to post
Share on other sites

I think the op meant how to organise it's files. Keeping them all in the same folder is usually a good idea, unless you have a very large number of classes, then separating them in folder would make more sense.

Share this post


Link to post
Share on other sites
All good and I will look into them.

What I am referring too is this. ......

Lets say in the future I write a snippet of code that calculates all even numbers up too n. By some miracle ive got it working on a few lines of code. Now I can forget ive done that once Ive finished that. Or I can store it somewhere for potential future use.

Share this post


Link to post
Share on other sites

All good and I will look into them.

What I am referring too is this. ......

Lets say in the future I write a snippet of code that calculates all even numbers up too n. By some miracle ive got it working on a few lines of code. Now I can forget ive done that once Ive finished that. Or I can store it somewhere for potential future use.

 

 

Manage it as you go along.  I use JsFiddle for my JavaScript functions that I write, just look for somewhere to put your stuff and then think no further of it.

Share this post


Link to post
Share on other sites
Sign in to follow this