3

We have been using Force.com IDE (Eclipse) to develop Apex and LEX. We notice if 2 developers accessing same file, it will be over-written by latest changes without prompting the user. So we have to keep backups always in order to avoid losing source code?

I tried to find a possible setting or extension to run compare/diff check before saving in Eclipse.

I'm using Eclipse Work Online mode (which saves code to Salesforce when we pressed Save).

Is it possible to configure some setting in Eclipse to avoid this? Thanks.

1 Answer 1

7

The problem is that there's no real guaranteed way to prevent overwrites, although the Force.com IDE does try to prevent this by performing a synchronization first. The problem here is that synchronization has a window where updates can be missed, between the synchronization and update process. Even the best synchronization tools are pretty basic, so there's a good chance that even if you do synchronize religiously, you'll overwrite or lose some code sooner or later.

This is why salesforce.com has given us Salesforce DX. Using Salesforce DX, we instead commit code to a repository, which we can then synchronize with our orgs as we work. Non-conflicting merges happen automatically, and conflicts are flagged on commit so you can resolve them manually. Best of all, you can use DX with the Force.com IDE, or other IDEs of your choice.

To get the most of it, you'll probably want to install Force.com IDE 2. It's a total rewrite designed to utilize DX, so that you can get the most out of it. You can also take advantage of Scratch Orgs, which basically let you play around with your own copy of an org, avoiding potential accidents by not working in the same org as other developers.

And yes, you should be using backups. But not just normal backups, like copying the entire org to a disk. Instead, use a source code repository. This allows you to make sure that concurrent modifications will merge together, even within the same file, and if code is overwritten, you can easily rewind or review changes to a particular file.

Note that this synchronization problem isn't strictly salesforce.com-specific. All software development teams tend to cause conflicts from time to time, and a source code repository is how those conflicts are trivialized. If you're not using a repository, it's like driving without car insurance; you may go many years without an accident, but when you have that accident, you'll be sorry you didn't have the insurance.

Likewise, all software development teams, even a team of one, can benefit from source code repositories, and you should be using one. If you're not, I suggest that you get started today. The Force.com IDE supports Git out of the box, but if that's not your thing, you can use other services, like Team Foundation Server or Subversion (SVN). I strongly recommend that you head over to Salesforce Trailhead and go through the Git and GitHub Basics module. Your future self will thank you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .