Maintaining a code library

Started by
4 comments, last by Death-A-Lot 10 years, 3 months ago
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?
Advertisement

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!

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

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".

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.

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.

This topic is closed to new replies.

Advertisement