Jump to content

  • Log In with Google      Sign In   
  • Create Account


Maintaining a code library


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Death-A-Lot   Members   -  Reputation: 107

Like
0Likes
Like

Posted 10 January 2014 - 11:14 AM

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?

Sponsor:

#2 Glass_Knife   Moderators   -  Reputation: 4085

Like
2Likes
Like

Posted 10 January 2014 - 11:33 AM

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"
Indie Game Programming

#3 Mnemotic   Members   -  Reputation: 340

Like
0Likes
Like

Posted 10 January 2014 - 01:11 PM

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



#4 Vortez   Crossbones+   -  Reputation: 2697

Like
0Likes
Like

Posted 10 January 2014 - 01:49 PM

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.



#5 d4n1   Members   -  Reputation: 423

Like
0Likes
Like

Posted 10 January 2014 - 02:10 PM

Best way to organize the code is based on how easy it is for you to access...I don't know how to make you more efficient.



#6 Death-A-Lot   Members   -  Reputation: 107

Like
0Likes
Like

Posted 10 January 2014 - 02:39 PM

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.

#7 d4n1   Members   -  Reputation: 423

Like
0Likes
Like

Posted 10 January 2014 - 02:53 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS