Starting a project

There are multiple ways to learn how to code. Some people do it with some kind of formal education like high school, university, master… Other people through Bootcamp or more modern initiatives we are seen lately. And, finally, there are people that it learns self-studying. No matter which one is your case, at the end of the day, the best way to learn and acquire some coding skills is to code.

As developers, we code (we do other things, not just code). Usually, if we do it professionally, enterprises have their tools and procedures. This is not the scope of this article. This article is going to focus on small projects we start outside these corporative environments, just for fun, for learning purposes or, because why not? And, I am talking about projects, not just code snippets or small demos trying something we have read in an article or blog, or testing this crazy idea we had in mind the last few days.

The purpose of the article is to offer some guidance on possible free tools we can use to work on a project following more or less a methodology and using some tools similar if not the same than the ones you can find on a corporative environment.

The focus of the article is people learning how to code to allow them to have a bigger picture, or people starting a long term open-source project, or just anyone curious. It going to focus not on the coding part but on the areas around the project.

Every project when it starts it needs a way to manage the code and a way to manage the efforts. I am certain about the first one, all of you agree but, I can hear from here people questioning the second one. Well, initially, and especially if we are the only developer, we can think it is not necessary but in the long run, even more, if we expect contributions in the future, it is going to be a very useful thing to have. It will keep our focus, it will make us think in advance, to do some planning and, it will give us a history of the project and why we took a certain decision at a certain point or why we added a concrete functionality. And, if you are learning how to code, it will give you the bigger picture I was talking about before.

To manage our code we need some kind of distributed version control system for tracking changes. There are a few of them out there like Git, Subversion, Perforce, Team Foundation Version Control or Mercurial. If you stay long enough in the industry, you will see all of them but, in this case, my favourite preference is Git. There are some cloud platforms that offer you an account to use it (GitHub, GitLab, Bitbucket). All of them are similar and at this level, there is no big difference, I invite you to test all of them but, in this case, I am going to recommend GitHub. I like it, I am used to it, it is hugely extended among the open-source community, and, integrates easily and smoothly with other tools we are going to see in this article.

To manage our efforts we need some kind of project management software tool for tracking tasks and the progress of them. As in the previous case, here event more, there are a lot of them out there. One very simple to use and very extended is Trello. Trello offers you some customizable boards we can use to track efforts, progress and plan in advance. In addition, there are a lot of useful plugins to improve and highly customize the boards and the cards (tasks) there. Here just a quick mention to the ‘Projects’ tab in GitHub that it allows you to create some automated Kanban boards. It is interesting to play with it. But, I have never seen it in a corporative environment where I have seen Trello multiple times. The first place here is for JIRA.

Once we start coding, creating pull requests and merging code in our repository it is nice to have in place a CI/CD environment. There are multiple advantages of this but, even if we are just learning, it will keep your code healthy making sure that any change made still compiles and pass all our tests. Again, in this category, we can find some cloud platforms and on-premises solution but, for the article, I have chosen Travis CI (the dot org). It is simple to register, great integration with GitHub, powerful enough and well documented.

One thing that developers should be worried about it is the quality and maintainability of the code they write. And, I am not talking just if our code passes all the test, I am talking about bugs, vulnerabilities, test coverage, code duplication, format (we should be using our IDE auto-format or save actions for the last one). To cover all this list we can find the tool SonarQube, and a cloud solution SonarCloud. This tools will report us with all the found problems every time a build is done, allowing us to correct them as soon as possible and not let them pailing and just be found when there is a code auditory or similar. Again, it is an easy tool to manage and to integrate with GitHub and Travis CI.

Are these tools the best ones? The more useful ones? Yes, no, maybe. I am a strong believer that there are not perfect tools, there are tools perfect for a job and, this is what sometimes we as developers need to decide, which tool fits best the job. The tools in the article are just examples and, they were perfect for the article.

Starting a project

Publishing to GitHub

GitHub is a web-based Git or version control repository and Internet hosting service. As a developers, I am quite sure that all of you know the platform.

Every-time we start a new project, even if it is just something for us, it is a good idea to use a version control system. Here is where Git and GitHub can help us.

There are two easy ways to create and upload our project to a repository.

The first way, it is to create the repository in GitHub, and after that clone in our machine the created repository and start writing our code. This is the simplest way. Doing it in this way, our local repository is already connected to the remote repository and we just need to start committing things. The clone command, assuming the account name is “fjavierm” and the repository name is “myproject”,  is:

git clone https://github.com/fjavierm/myproject.git

Te second way, it is when we already have a project in our local machine and we want to add the project to a repository. In this case, we need to perform a few more steps.

  1. We need to create the repository under our GitHub account. In this case, my account is “fjavierm” and my repository is going to be “myproject”.
  2. In our local machine, in our local project folder, we need to initiate the git repository. This will add a folder “.git”: init
  3. We can check the status of the available files: status. This instruction will show us the files that we can add to the repository to commit. In this step, it deserves to pay special attention to the files that we do not want to add and, maybe, it is a good idea to create the files “.gitignore” and “README.md”
  4. Add the files to the repository.
  5. Commit the added files adding a descriptive message. Usually, issue number and description, or something meaningful.
  6. Connect our local repository with our remote repository.
  7. Check we have perform the previous step properly.
  8. Push our changes to the remote repository.
git init
git status
git add .
git commit -m "Starting the project."
git remote add origin https://github.com/fjavierm/myproject.git
git remote -v
git push -u origin master

With these few instructions we should have available all our code in the GitHub repository.

Publishing to GitHub