views:

46

answers:

4

I'm taking a programming course. I did my first assignment in an HG repo called Assignment1. Now the second assignment is out, and it appears that I'll be able to use large chunks of code from Assignment1 as a base for Assignment2.

A few options I see are:

  • Copy and paste the relevant code; create a new repo for Assignment2
  • Continue committing to Assignment1 in a tagged branch
  • Conintue committing to Assignment1 in main

Is one of these better? Is there another option I'm not thinking of?

A: 

I think branch is the way to go here. If you continue committing in main, tag what you handed in for Assignment 1.

pjmorse
A: 

If Assignment 2 is just additions to Assignment 1 with the same scope I would continue committing to Assignment 1 in main.

If Assignment 2 is a new program with a different scope I would attempt to isolate as much reusable code into a Library. So I would go with Copy and Paste the relevant code. I would create two separate repos: one for the Common Library Functions/Classes and another for Assignment 2.

Shiftbit
A: 

sometimes when doing a programming course the whole project is composed of small sub-projects that bring more and more functionality to the project

  • e.g.: Project = Assignment 1 + Assignment 2 + Assignment 3 + ... + Assignment n

In this case, you should keep your code in 1 repository.

If the assignments don't contribute towards a final "common" project, keep separate repositories.

This of course is the way to go for regular projects. For small projects, maybe during a course, you can improvise and select the way which is best in that case.

Does this help?

udo
A: 

I agree with pjmorse. I think Branch is what you need.

RJia