tags:

views:

43

answers:

3

I just had a conversation with my manager relating to checkin\out policies on a project I'm currently working on. Basically I tried to edit a file that was already checked out by another developer and I couldn't - I asked my manager why we couldn't edit the same class at the same time and he gave this reason for turning that functionality off: We had a lot of problems with developers editing the same Form (or anything visual done in the designer) and then cheking it in. Merging the changes in the designer generated code was a lot of hassle...

As I'm writing this I'm struggling to see what problem they were having - surely they were getting the latest code before trying to check something in??

Anyway,

My question is this: Have any of you come across problems with editing the same Form (or something in the designer) as another developer and then checking into TFS? If so how did your team get around the problem? Did you also turn off the ability for developers to work on the same class?

Cheers,

James

EDIT: The following post (found here) is exactly the problem my manager was describing. Anyone know of a simpler way to resolve the issue than the ones in that post?

+2  A: 

I've just checked back through the histories of some of my .designer.cs files and I can't see any changes that would cause a merge problems. There were no wholesale rearrangements of code for example.

Another thing to consider is to make sure that everyone does a "get latest" at regular intervals then any individual merge/resolution isn't going to be that great thus minimising the chances of anything going wrong.

It might also be worth investigating a 3rd party merge tool. There are plenty around.

Now it could be that the changes I've done are simple compared to the ones you've got so you should take my anecdotal data with a pinch of salt.

ChrisF
+1 for "Get Latest". Regarding 3rd party merge tools-- I've actually been very impressed with Microsoft's latest included merge tool, and haven't felt the need to look any further.
Robaticus
along with "get latest" you need to ensure that developers are checking in small, frequent changes--the smaller the changes to merge, the better the chances the results are correct
STW
+2  A: 

I would argue that the solution to your problem would be to establish best practices for source code modification.

Discourage people from going into UI code and arbitrarily jiggling the components around in the designer. Any reasonable UI modifications should be easily mergeable. Your best bet is to try and educate people as to the best way to merge in any given source control system. Also, as helpful as the designer is, ignorance of what code is being automatically generated in the background will be significantly detrimental in the long-term.

People who insist on locking checked-out files for the reasons you stated in your post typically wait long periods of time to check their code in. Naturally, the more time passes, the more code gets modified, so it makes merging difficult for these people. Checking in early, often, and incrementally requires people to think about their changes in stages, and for some coders, this is a rather painful cultural/psychological adjustment.

warriorpostman
+1  A: 

It can cause problems (in general) when a lot of people are editing UI concurrently. The merge logic will do a fine job merging things, but in a lot of cases the UI is drawn according to how things are added to the form. Your UI can get messed up quickly.

I don't know if I would use this as an excuse to enforce exclusive checkouts across the board, though. I might go from a (non programmatic) policy standpoint that says shared checkout for business logic, but exclusive for UI changes.

I would couple that with a strong MVP, MVC, or MVVM approach, though, which should limit the number of people that have to touch the UI concurrently.

As others have alluded to, keep one of the seminal rules of SCM in mind: merge early and often, and your problems are reduced. (along with that is "always get latest before you start working on the code).

Robaticus
Yeah I completely agree with you and Chris. I think the current process regarding builds is a little slack which is why they experienced problems in the past. I'm used to running a .bat that gets the latest and then builds everything locally (all merge issued are resolved here) then checking in afterwards to trigger the CI build - 99% of the time it passes because all issues were resolved in the local build.
james lewis