Open Source 101
An unconventional introduction to open-source…
In open-source people join together and create software for free. The software made is publicly available, which means it can be modified and redistributed by anybody.
Example of open-source softwares are: vlc media player, mozilla firefox, ubuntu(and all linux), python programming language etc.,
Many questions may arise in your head — why, how etc. Grab a cup of caffeine and pair of spectacles, the answer lies ahead!
Why should I contribute to open-source?
- Companies consider your open-source contributions seriously. It will make your resume/CV that much more valuable than a pet project.
- You will learn industry best practices and your code quality will improve dramatically.
- You will comes across a lot of different technologies, the skills you acquire can be directly used in a software engineering job.
- It will show that you can work with a lot of people and your communication skills. Which are important traits for any job and have been looked after by all companies.
- You will contribute to a good cause and your work is likely to be used by thousands or millions of people.
How open-source software is created?
- An Issue is created.
- The issue is fixed by Pull Request.
I am not kidding that’s all it takes. All the other complexity and coding stuff comes under these two steps.
What is an Issue?
- Issue may be one of few things: a new feature request, a bug report, a code remodelling request, a documentation update request etc.,
- Issue is a well defined description of a single problem to be solved.
- Our example Issue #487 is a bug report
- Here I asked one of the project maintainer to assign this issue to me. So others wont work on the same issue. Reducing duplicate efforts.
What is a Pull Request:
A Pull Request(PR) is a piece of code written to fix a particular issue. Since you request to “pull” your code from fork to original, it is named as a “pull request”. These are the steps taken by me to create Pull Request #459.
Create fork of the repository and setup project in my local machine:
Forking a repo means creating your own personal copy of the original repo. I cloned the forked repo into my local machine. Setup the project as the instructions provided.
Finding the bug and fixing it
I tried a few ways to find the bug. Finally I discovered that the solution is this 2 lines of code ( LOL ) . Made the fix. Wrote a comment. Made a commit.
Write test cases for the fixed bug
A test case consists of an input to the code and an expected output. I am just simulating the scenario and checking whether I get the correct output.
Ensure that my additional code doesn’t break any existing logic!
This can be achieved by running the test cases written by the previous developers. Since it ran the tests successfully, now we can safely push the code to the fork.
Create the pull request
We can now compare the changes between our fork and original repo. The changes are made into a PR.
Once the PR is made Automatically the CI (Continuous Integration pipeline) kicks into action. It checks if the PR code is good or faulty. If it is all good, we will get a green check mark. Then a maintainer of the repo checks the changes. If he/she is satisfied with the code, then the PR will be merged.
This concludes one life cycle of code contribution. we repeat the same cycle with another Issue.
Things to take away:
- Open Source is not a hackathon or a freelance project.
- Things are to be performed is a systematic manner.
- So try to get assigned an “Issue” and break down the complexity into small consumable chunks.
- PR’s will take even 1 or 2 weeks to be merged.
- Patience is key.
- You can work on multiple PR’s at the same time.