CO886: Software Engineering
Tools for collaborative development






Tomas Petricek

email: t.petricek@kent.ac.uk
twitter: @tomaspetricek
office: S129A

Software engineering today

Mathematician's answer to software engineering

Use mathematical methods to prove system correctness

People don't do it, yet, software mostly works.

Detailed upfront models

We know where
we want to get

Useful if predictability matters more than cost and delivery time

Software engineering today

In contrast to upfront model

We know that we continue
moving in the right direction

Tools and practices to ensure that

  • We can learn from past mistakes
  • We're tracking known issues
  • Software keeps working when we make changes
  • It is easy to improve and contribute

Software engineering today

Some important aspects that we will cover

Source control and collaborative development

Testing and build automation

Continuous integration and reproducibility

How open-source software development works

Git and source control

Version and history tracking systems

Keep version history because you will need to look back

Develop features independently and merge changes

GitHub and collaboration

Help teams plan and collaborate and organize

Manage issues, notes, plans, contributions

Also a "social network"
for open source software

Git and source control

Git repository

Everything in one folder

  • Your regular files you can edit
  • .git folder with old versions etc.
  • .gitignore and other special files

Versioning and collaboration

  • Stage changes from files to "index"
  • Save or retrieve from version history
  • Push to/pull from remote repositories

Working directory
Files you directly edit

Staging area
Selection to be archived

Local repository
History and versions

Remote repositories
Versions on other computer(s)

Creating repository and adding files (1/2)

Initialize empty repository in current folder

1: 
2: 
$ git init
Initialized empty Git repository in C:/Temp/test/.git/

Add new or modified file to the index

1: 
2: 
3: 
4: 
$ git add hello.txt
$ git status
Changes to be committed:
        new file:   hello.txt

Creating repository and adding files (2/2)

Create new version history record (commit)

1: 
2: 
3: 
4: 
$ git commit
[master (root-commit) d70e7d9] Adding hello file
 1 file changed, 1 insertion(+)
 create mode 100644 hello.txt

List the most recent history records

1: 
2: 
3: 
4: 
5: 
$ git log
commit d70e7d97c8598b8c55f01da803447cf95d664504 (HEAD -> master)
Author: Tomas Petricek <tomas@tomasp.net>
Date:   Sat Feb 9 01:36:40 2019 +0000
    Adding hello file

Demo: Creating repository, adding files

Warning: This slide contains profanities

How to write a good commit message?

Brief summary of the change (70 characters)

Add more detailed comment after a newline

Git history and branches

Using git for versioning and features

Use branches for different versions and features

Branch is named pointer to a commit

Master branch is typically the "main" once

Branch for each version running in production

Git history and branches (1/3)

Directed acyclic graph
Commits identified by hash
Arrow to a previous state

Git history and branches (2/3)

Directed acyclic graph
Commits identified by hash
Arrow to a previous state

Commits, branches, head
Branch is a pointer to commit
Current branch identified as HEAD

Git history and branches (3/3)

Directed acyclic graph
Commits identified by hash
Arrow to a previous state

Commits, branches, head
Branch is a pointer to commit
Current branch identified as HEAD

Merging changes from branches
Commit with multiple parents
Potential for conflicts

Working with branches (1/2)

Create and switch head to a new branch

1: 
2: 
3: 
$ git branch testing
$ git checkout testing
Switched to branch 'testing'

Make a change in a new branch

1: 
2: 
3: 
$ git commit -am "Add experimental features"
[testing 4aaea6a] Add experimental features
 1 file changed, 2 insertions(+), 1 deletion(-)

Working with branches (2/2)

List branches and switch to master

1: 
2: 
3: 
$ git branch -v
* master  d70e7d9 Yadda
  testing 4aaea6a Adding testing

Merge changes from another branch

1: 
2: 
3: 
4: 
5: 
6: 
$ git checkout master
$ git merge testing
Updating d70e7d9..4aaea6a
Fast-forward
 hello.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Demo: Working with branches

Git and its alternatives

When is git a wrong tool and alternatives

Uses distributed model with no central server

There are user interface tools for using git

Git is way more complex than it seems

Alternatives include Subversion, Mercurial, Perforce

Collaboration and GitHub

GitHub collaboration platform

Other things a project needs

  • Tracking issues and feature requests
  • Hosting documentation and notes
  • Integration with test runners, etc.

Why open source uses GitHub

  • Convenient way of storing my projects
  • Active developer community
  • GitHub is (a bit) like your CV

GitHub projects

Git repository with history, branches etc.

README and a few other special files

Additional features
not based on Git

Additional GitHub features

What exists in GitHub, but not in git

Fork a project to create your clone in your profile

Send pull requests between multiple forks

Track issues and organise projects

Use wiki for keeping notes and documentation

Working with remote repositories
Same thing as your
local repository!

Clone to copy data
Pull to fetch changes
Push to update remote

Working with remote repositories (1/3)

Clone a remote repository from GitHub

1: 
2: 
3: 
4: 
5: 
6: 
$ git clone https://github.com/tpetricek/test.git
Cloning into 'test'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.

Go to the new folder and edit the code

1: 
$ cd test/

Working with remote repositories (2/3)

Modify repository locally offline

1: 
2: 
3: 
$ git commit -am "Modifying readme for test project"
[master 59bb116] Modifying readme for test project
1 file changed, 1 insertion(+), 1 deletion(-)

Push local changes to remote repository

1: 
2: 
3: 
4: 
5: 
6: 
7: 
$ git push origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 271 bytes | 271.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/tpetricek/test.git
   59ea774..59bb116  master -> master

Working with remote repositories (3/3)

Retrieve changes done by others

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
$ git pull origin master
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/tpetricek/test
 * branch            master     -> FETCH_HEAD
   59bb116..1fd8ceb  master     -> origin/master
Updating 59bb116..1fd8ceb
Fast-forward
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Demo: GitHub projects, git push an pull

GitHub pull requests Sending contributions
back to project owner

Owner has write rights,
way to discuss changes

Linux uses patches and emails, not PRs!

Contributing to a project

Typical workflow when contributing on GitHub

❶ Fork project (GitHub) - Online copy in your profile

❷ Clone repository (git) - From GitHub to your computer

❸ Commit changes (git) - All in your local repository

❹ Push changes (git) - From your computer to GitHub

❺ Send a pull request (GitHub) - Online to the owner

Summary

Tools for collaborative development

Software engineering today
From "we know where we want to get"
To "know we continue moving in the right direction"

Using git for version and history tracking
Working dir, staging area, local and remote repositories
Creating, commits, working with branches, merging

Collaborative development using GitHub
Forks, pull requests, issues, etc.
Typical open source contribution workflow

CO886: Tools for collaborative development

What you should remember from this lecture

  • How git stores versions and branches
  • Git commit, branch, checkout, pull, push
  • GitHub forks, pull requests, etc.


Tomas Petricek
t.petricek@kent.ac.uk | @tomaspetricek