It so happens that we just found a bug that plagued us for 6 months, in the form of a commit that ignored completely the existing code in favor of a copy/paste from an internet source (I assume).
Now, let’s get one thing out first. I really really don’t mind having stack overflow code in my source. It has, over the years, established itself as a reliable way to fix thorny issues, or at least find pointers, and is probably todays numero uno origin of most code written by new programmers. That’s fine. Better than fine, it’s totally rad to have a community help students and people exploring new fields of our wonderful pitfall-laden world.
The second thing I want to point out is that I have worked freelance for 16 years. That should tell you my teamwork leaves a lot to be desired. I know that.
Now, every now and again, I still have to work with existing code, being updated while I work on the project. That’s fine too. However, successful collaboration, especially on code, relies heavily on communication, and prepwork.
So, without further ado, the Cardinal Rules of Team Code Editing (at least when I’m involved):
- Thou shalt have a clearly defined “ownership” system. What parts of the code are you responsible for? What parts has someone else in charge?
- Thou shalt have a clear way to communicate the changes thou art making. No, commit logs aren’t enough. At least not on their own.
- Thou shalt always check thrice as much when changing code thou doth not have ownership thereof. If you “fix” something in someone else’s code, you’d better be pretty bloody sure you understood how the owner made that piece work.
- Thou shalt notify the owner of the code of thy changes. Email, Slack, IM, Skype, I don’t care how.
- Thou shalt make sure your changes art reversible. Possibly by having separate commits for each piece of the project that is owned by a different author.
- Thou shalt not update critical pieces of thy project that are tied to a specific setup. Kind of an off the cuff unrelated item, but next time I have someone update the friggin project file with their own heavily personal paths, I’ll ‘git rm -rf’ everything. Be warned.
I know it sounds like a rant from a totally pissed lunatic, but beyond the anger, I actually believe these are sensible (and scalable, even if you have different layers of ownership) rules that would make everybody’s life better if thoroughly applied.
Feel free to add your own in the comments.