Open Source Best Practices
Tags: opensource, webdev, computerscience, codenewbie
Published: 2021-05-15 17:10:04

Open source has always been an amazing place to learn, collaborate, contribute and build new stuff. Having been a part of many open source communities, events, and organizations, I have realized that people are slowly and steadily understanding the potential of open source as the future of technology. However, they often get confused regarding the workflow in open source projects and communities and end up doing mistakes that lead to not-so-good contributions and thus, often get stuck in a loop of code reviews and changes before they ever make a meaningful or effective contribution to a project.

**Note:** This article can only be helpful if you are familiar with the basic git terminology and have an understanding of the initial workflow of using git and GitHub.

> Read here for more info: [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)

Here are some of the best practices that you can take up for your next contribution!

### Culture and Communication

Open source communities are a big pool of people from different social and ethnic backgrounds, races, religions, and languages. Thus, the best way to walk along with everyone would be to practice empathy. 

- Always ensure that your tone stays friendly and respectful in a discussion. 
- Try to adapt your language to non-native English speakers as they might find the environment challenging or intimidating at times.
- Stay humble and modest. None of us know everything, we are all learning. Some developers might need help with something that is very basic, be kind, and extend a helping hand whenever you can.

![Remote-Work-Culture.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1620929342550/vBKmgHn93.jpeg)

- Try to learn yourself as much as possible, devote time to explore the codebase, and attempt to understand things before you ask a question on a public channel or open an issue. Even though, if you seem to be stuck with anything, do not hesitate to ask questions to fellow developers. Likewise, do respect the space and the questions put up by others.
- Be nice and welcoming. Appreciate your fellow developers and contributors of they did a good job. Extend a **" please "** or **" thank you "** in a discussion to express politeness and generosity.

![Emojis](https://github.blog/wp-content/uploads/2016/03/d55b8b7e-e6ba-11e5-9b31-59a8db92e456.gif?fit=917%2C359)


#### Communication Channels

Most of the open-source communities have their private or public communication channels like Slack, Discord, Gitter, etc as chat is a great way to connect with other contributors and maintainers.


![Discussions](https://cdn.hashnode.com/res/hashnode/image/upload/v1620929791597/WxvGy_4Ys.gif)

To use these channels effectively, contributors should try to follow the below points:

- Do not switch to private communication with a maintainer or fellow contributor until and unless very necessary, as this shuts out other contributors who might be facing the same issues and can get help straight away by reading the earlier conversation.
- Do not discuss feature requests and bug reports over chat, as they are best handled over GitHub or Issue Trackers.

### Feature Requests and Bug Reports

Feature Requests and bug reports are best handled over GitHub, but one must follow certain steps to use them constructively:

![68747470733a2f2f68656c702e6769746875622e636f6d2f6173736574732f696d616765732f68656c702f6973737565732f6e65772d69737375652d706167652d776974682d6d756c7469706c652d74656d706c617465732e706e67.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1620928822105/PNfx55FDh.png)

- For any bug or feature, no matter how small or big, open an issue with all the necessary details, and don't forget to indicate if you're interested in working on it.
- Try to include all relevant information when you submit an issue so as to help others understand it easily. Include links, information about the code that has to be changed, and screenshots wherever necessary.
- Break down a big feature request into smaller issues, so that more than one contributor can simultaneously work on it.
- Always remember to add steps to reproduce the bug that you are reporting while submitting a bug report. 

> Most open source projects use [Issue templates](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates) for Feature Requests and Bug Reports. These can be used as a reference to the details that should be mentioned while submitting an issue.

![Issue Templates](https://user-images.githubusercontent.com/877585/64684565-3c595a00-d47d-11e9-8ea4-589cffa16375.png)

![Details](https://vgpena.github.io/images/github-templates/good-issue.png)

### Development 
Once you have decided on the open-source project that you want to contribute to, the first step, to begin with, would be to set up the project on your local machine and run it. The steps are usually defined in the `README.md` file. The next step would be to go through the branch policies and [contributing guidelines](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/accessing-a-projects-community-profile) of that project, these can be easily found inside the `CONTRIBUTING.md` file. Once, you are done, you can begin with the changes in the project.

![setup](https://cdn.hashnode.com/res/hashnode/image/upload/v1620930564126/Jfng7D8_I.png)

Even meanwhile development, if you have any doubts or come across any challenges, feel free to ask questions from the maintainers or the fellow contributors. (You can use either the communication channel or keep the conversation over GitHub.)

### Commits and Pull Requests

Most first-time contributors are hesitant or fearful of making a PR, although, there's no need to be afraid, just keep a few things in mind while making your PR to get a quick code review and feedback:

- Write meaningful commit messages, that convey what changes have been done. For example -

![commit message](https://neighbourhood.ie/assets/blog-images/semrel-1.png) 

- Ensure that you use the minimum number of commits for a change. In case, you have a lot of commits for a small fix, [squash](https://levelup.gitconnected.com/how-to-squash-git-commits-9a095c1bc1fc) them before making a PR.

![Squash](https://user-images.githubusercontent.com/2996465/57393418-a8068000-7188-11e9-9167-2471a634a47c.gif)

- Do only the changes in the PR that were mentioned in the issue. Do not change anything else that is not relevant to that particular issue.
- Always link your PR to the issue that it fixes. Learn how to do it [here](https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#:~:text=On%20GitHub%2C%20navigate%20to%20the,to%20link%20to%20an%20issue.).


![Linking PR](https://cdn.hashnode.com/res/hashnode/image/upload/v1620930949750/78DUGiXhd.png)

- Make PRs from your own forks (even if you have the rights to the repo, do not create new branches, develop on your own branches).
- State the actual enhancements or changes done in the PR rather than just mentioning `Fixes #1`. Refer to the PR template for details to be mentioned, if the project has one.
- Remember to add a screenshot or video if you have made any UI changes. This boosts up the review process exponentially.

![Demo](http://www.kianyang.co/wp-content/uploads/2018/01/blog_git_commit_v2.gif)

- Help the reviewers solve merge conflicts if any. Read more about merge conflicts [here](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/addressing-merge-conflicts).

![Merge Conflicts](https://github.blog/wp-content/uploads/2016/12/fd64b010-c06b-11e6-9dd3-a827e299c5bf.gif?fit=1360%2C426)

### Documentation

Everything in open-source happens through an exchange of words. Thus, documentation stands as a crucial step to provide information about your contribution.

> Documentation is a continuous effort at every step of software development.

- Add information on the new technologies, frameworks, libraries, and the code into the code itself via comments and into documentation files e.g. into the `README.md` or `/docs` folder.
- Always help to keep documentation up to date and make it easy for new contributors to join the project.

Last but not the least, open-source is a collaboration between many different people with many different priorities, and sometimes, you got to wait until the right time. The other people working on a project likely have very different lives than you do, and their priorities may not match up with yours. Work projects, vacations, and family are some of the most common things that can push back a response to your needs and patience is the best way to deal with it. Since great things are worth the wait, never mind the delay.

This is all that I learned along my journey in open-source. I hope that the practices mentioned above take you closer to your next **(effective)** open-source contribution and help you fulfill your chance to give back to the community, one commit at a time!

If you find this insightful, do let me know your views in the comments. Also, any kind of feedback is welcome. In case you want to connect with me, follow the links below:

[LinkedIn](https://www.linkedin.com/in/pragativerma18/) | [GitHub](https://github.com/PragatiVerma18/) | [Twitter](https://twitter.com/pragati_verma18) | [StackOverflow](https://stackoverflow.com/users/10364459/pragati-verma)