How and Why to Contribute to Open Source

Ashay Mandwarya 🖋️💻🍕
HackerNoon.com
Published in
8 min readJun 19, 2019

--

Photo by Yancy Min on Unsplash

If you are here reading this article, it means you atleast have an idea about Open Source. This article aims to be a launch pad for developers and programmers who still don’t contribute to the Open Source community but want to. It will talk about the How and the Why aspect of Open Source contribution.

As you probably have known that open source has changed the face of the software industry and the modern computing world in general and will continue to do the same in the future. Open Source community has tons of awesome developers still it requires your contribution because every drop counts. It does not matter if it is a small contribution or something substantial. Everybody starts like that and soon as you contribute more and more you will become an expert too.

A journey of a 1000 miles starts with a single step.

Requirements for contribution to OSS

Some of the most basic requirements which are required for contribution to OSS are

  • Good understanding of one programming language of your choice

Understanding of a programming language not only just includes knowing the syntax or how loops and recursion works. If you are already familiar with that, Good for you! You crossed the first level. Next up you need to take up the task of learning the many tips and tricks related to that language. After that you should consider learning and using major libraries and packages that are going to be used in any medium to large-scale projects. You should look up for relevant libraries related to your programming language and devote time to learning them. A good understanding of the languages will help you go a long way in understanding any code base better.

  • Version Control System

Any sort of version control system is a must for any open source project, as there will be tens of thousands of contributors and as they will be making changes to the source code independently a system is required for managing so much changes, as the number of contributors increase it becomes very difficult to accommodate all the changes manually.

Yes, this is where Git comes in. Version control systems such as the as the likes of Github and SVN are the way to do collaborative coding which makes sure that all the code remains secure and concurrent at any given point in time throughout the project. All, and I mean ALL, organizations/projects use some form of version control. Although now, mostly every organization/project have switched to Git for some of its features, while some might still be using SVN. Github is just a Git client which lets you host your code online. As we can see the importance of Versioning Systems it is very important to have a good idea of how these systems work and also to know about all the features they come with. Therefore, first, learn Git , then move on and learn how to use Github.

  • Learn to read the Source Code

If you have worked on an open source project before (which I think you didn’t, that’s what you are here for) or used a tool or other software, you might have noticed that most of them come with a documentation and mostly they are all crap. Very rarely you come across a documentation which tells you about the project or software in a direct and easy manner, and moreover having a good documentation isn’t enough, there is no substitute for the ability to read through gigantic code spanning thousands to millions of lines of code. The documentation may be useful for the end user, but for any new developer, it may appear gibberish. You are on your own when you need to go through the source code of something which spans n number of lines with n number of files across the project.

The question arises that, Where does one start? It’s not an easy question to answer but I will try my best.

You should learn how to use bug and issue trackers which almost, every project uses. If you don’t know what a software bug is, it will be a good time to start and learn about this. Bug trackers are like version control systems which we talked about earlier. In fact, most version control clients will have an implementation of the bug tracker themselves. Github also has an issues. A bug tracker, basically, lists all the “issues” (or bugs) currently identified with the software and their “status”(Are they solved? Unsolved? Being worked on?). Bug trackers provide the non-developer end-users with a way to point out a problem in the software. They might also be used to request a new feature, which is different from a bug.

  • Submit Patches

Submitting patches means submitting the changes you made to the project. The changes might include fixing bugs or adding new features to the project. These patched are submitted to the respective owners and moderators of the project.

Once you’ve learned all of the above, you are ready to submit some patches or bug fixes to a project of your choice. Choose any open-source project — preferably written in a language you know, and more importantly, interests you — and go and browse through its bug tracker. Most bug trackers have issues marked as volunteer or introductory. Search for such issues, or go with any issue which you think you can fix. Comment or write an update on the issue saying you are taking it up. Solve it on your local system (you’ll know what this is once you know how to use version control) and then push it to the organization’s remote code base. This is easier said than done. You’ll need to know the following, at the very least:

  1. What version control system the project is using.
  2. What are their workflows for code contribution? (Most organizations/projects have a defined way to submit a patch which must be followed). The contribution guidelines can be found at the contribution.md file in the project structure
  3. How to get involved with the community.
  4. You must practice and gain expertise in the above procedures as they serve as the building blocks if you want to be a good contributor to the community.

Creating an app for deployment

Lets make a simple chat application using and deploy it to github making it open for contributions from the community

We will be creating the app using JavaScript, Node.js, Experss and Socekt.io. Node.js is a JavaScript run-time environment which helps JavaScript run outside the browser(Back-end). Socket.io on the other hand is a JavaScript library which helps in bi-directional communications between client and the server. Express is a Node framework used to make working with Node simpler.

For simplicity this article will only focus on the back-end part which is required for making a basic app and wont focus on the UI part.

Follow the steps below and you will be ready with the app in minutes.

  • Using npm install Socket.io and Express.js and include them in your project.
  • Include Express in your file, which will be used to create a server which will ultimately help in communications and logic implementations.

var app=require(‘express’)();
var http=require(‘http’).Server(app);
  • Include Express and call http module for server creation

The above code is used to make a call for the express module and to make a call to the http module which contains methods essential for creation of the server.

Now when the server is created we need to host it on a port.

var app=require(‘express’)();
var http=require(‘http’).Server(app);
http.listen(3000,()=>{console.log(‘Listening on port 3000’);})

Server hosting

The above code is used to host the server on the given port. Whenever the server is up and running a message is logged on the console.

Defining routes

You define a route handler / that gets called when you hit the website home.

var app=require(‘express’)();
var http=require(‘http’).Server(app);
app.length(‘/’,(req,res)=>{
res.send(“<h1>Chat Application</h1>”)
})
http.listen(3000,()=>{console.log(‘Listening on port 3000’);})

Create an HTML file to serve whenever the server is fired.

<!DOCTYPE html>
<html lang=”en”>
<head>
<title>Socket.io chat</title>
</head>
<body>
<ul id=”messages”></ul>
<form>
<input id=”a”/><button>Send</button>
</form>
<script src=”/socket.io/socket.io.js”></script>
<script>
$(()=>{
var socket=io();
$(‘form’).submit(()=>{
socket.emit(‘chat message’, $(‘#a’).val());
$(‘#a’).val(‘’);
return false;
});
});
</script>
</body>
</html>

Include socket.io in the server.

var app=require(‘express’)();
var http=require(‘http’).Server(app);
var io=require(‘socket.io’)(http);
app.length(‘/’,(req,res)=>{
res.send(“<h1>Chat Application</h1>”)
})
io.on(‘connection’,(socket)=>console.log(‘A user connected’));
http.listen(3000,()=>{
console.log(‘Listening on port 3000’);
})

This is a very basic example of a chat app. This article is aimed at how to contribute to open source so it does not goes in detail of how the app is made. The app is a simple chat web app and we will see how to deploy it to github and open it for contribution.

Open sourcing your project

So you’re thinking about getting started with open source?

Congratulations! The world appreciates your contribution.

There is no perfect time to open source your work. You can open source an idea, a work in progress, or after years of being closed source.

To open source a work every project should include the following documentation with the project:

  • Open Source License
  • README
  • Contributing Guidelines

Open Source License- An open source license guarantees that others can use, copy, modify, and contribute back to your project without repercussions. It also protects you from legal situations. You must include a license when you launch an open source project. You can know more about how and what license to use for the project using one of my previous article [link to license article]

README- READMEs do more than explain how to use your project. They also explain why your project matters, and what your users can do with it.

In your README, try to answer the following questions:

  • What does this project do?
  • Why is this project useful?
  • How do I get started?
  • Where can I get more help, if I need it?

Contributing Guidelines- Contributing guidelines are found in the CONTRIBUTIG.md file. Contributing file contains guidelines regarding-

  • How to suggest new features
  • How to file a bug report
  • How to run tests
  • How to set up your environment
  • How to set up the project in local

It might also contain information regarding your vision for the project rather than technical information like

  • What you want your project to evolve into.
  • What you don’t want your project to evolve into.
  • What type of contributions you are looking for.
  • How contributors should reach you.

These are just basic steps which are a must for the contribution. If you follow all the guidelines, someone eventually might found your project who thinks your project is worth their contribution. You might spread word about your project on different websites asking for contributions. As more and more contributors contribute to your project, you will see it develop in ways and in magnitudes that you won’t even have imagined yourself.

--

--

Ashay Mandwarya 🖋️💻🍕
HackerNoon.com

Coder by day• Writer by night • Dreamer • Pizza Eater• All things JavaScript