Setting the Scene


Section 1: Setting Up Environment For Collaborative Code Development


1.1 Introduction to Our Software Project


Figure 1

Snapshot of the inflammation dataset

Figure 2

Software project fork repository in GitHub

Figure 3

Making a fork of the software project repository in GitHub

Figure 4

View of your own fork of the software repository in GitHub

Figure 5

URL to clone the repository in GitHub

1.2 Virtual Environments For Software Development


Figure 1

Python environment hell XKCD comic
Python Environment Hell from XKCD (Creative Commons Attribution-NonCommercial 2.5 License)

1.3 Integrated Software Development Environments


Figure 1

View of an opened project in PyCharm

Figure 2

Missing Python Interpreter Warning in PyCharm

Figure 3

Welcome screen in VS Code

Figure 4

View of an opened project in VS Code

Figure 5

VS Code Extensions marketplace for searching and installing extensions

Figure 6

  • Select Virtualenv Environment from the list on the left and ensure that Existing environment checkbox is selected within the popup window. In the Interpreter field point to the Python 3 executable inside your virtual environment’s bin directory (make sure you navigate to it and select it from the file browser rather than just accept the default offered by PyCharm). Note that there is also an option to create a new virtual environment, but we are not using that option as we want to reuse the one we created from the command line in the previous episode. Configuring Python Interpreter in PyCharm

  • Figure 7

    Packages Currently Installed in a Virtual Environment in PyCharm

    Figure 8

    Select python interpreter in VS Code

    Figure 9

    Set interpreter path in VS Code

    Figure 10

    Showing interpreter status in VS Code status bar

    Figure 11

  • Select the + icon at the top of the window. In the window that appears, search for the name of the library (pytest), select it from the list, then select Install Package. Once it finishes installing, you can close that window. Installing a package in PyCharm

  • Figure 12

    Installing a package in VS Code

    Figure 13

  • Select Add new run configuration... then Python. Adding a Run Configuration in PyCharm

  • Figure 14

  • In the new popup window, in the Script path field select the folder button and find and select inflammation-analysis.py. This tells PyCharm which script to run (i.e. what the main entry point to our application is). Run Configuration Popup in PyCharm

  • Figure 15

    Settings editor in VS Code

    Figure 16

    Run and Debug View in VS Code showing the option to create a new launch (run and debug) configuration

    Figure 17

    Syntax Highlighting Functionality in PyCharm

    Figure 18

    Syntax Highlighting Functionality in VS Code

    Figure 19

    Code Completion Functionality in PyCharm

    Figure 20

    Code Completion Functionality in VS Code

    Figure 21

    Code References Functionality in PyCharm

    Figure 22

    Code References Functionality in PyCharm

    Figure 23

    Code Search Functionality in PyCharm

    Figure 24

    Code Search Functionality in PyCharm

    Figure 25

    Search menu in VS Code

    Figure 26

    Search for a string functionality in VS Code

    Figure 27

    Search results window in VS Code with further filtering functionalities

    Figure 28

    Code search option in VS Code

    Figure 29

    Version Control Functionality in PyCharm

    Figure 30

    Version Control Functionality in VS Code

    Figure 31

    Running a script from PyCharm

    Figure 32

    Running a script from VS Code

    1.4 Software Development Using Git and GitHub


    Figure 1

    Representation of Git's distributed version control system showing interactions between a central repository and two local repositories on developer machines, with arrows showing pushing from central repository to developer repositories, pulling from developer repositories to central repository. A self-connecting arrow on developer repository shows creating commits in local repository.

    Figure 2

    Git commit tree showing four branches - Main, Develop, FeatureX and FeatureY. The Main branch shows three commits corresponding to release tags v0.1, v0.2 and v0.3. The Develop branch branches off from Main branch with intermediate commits between release tags which are then merged into Main branch. Short-lived feature branches FeatureX and FeatureY branch off from Develop branch, have a small number of additional commits and are then merged back in to Develop branch.

    Figure 3

    Code tab of GitHub web interface showing main branch of software project. Branch selector dropdown is shown with main (default) branch showing as currently selected and one other branch feature-std-dev showing as present.
    Software project’s main branch

    Figure 4

    Code tab of GitHub web interface showing notification indicating develop branch had recent pushes. Branch selector dropdown is shown with main (default) branch showing as currently selected and two other branches develop and feature-std-dev showing as present, with develop highlighted.
    Software project’s develop branch

    1.5 Python Code Style Conventions


    Figure 1

    Python code indentation settings in PyCharm

    Figure 2

    Python code whitespace settings in PyCharm

    Figure 3

    Python code whitespace settings in VC Code

    1.6 Verifying Code Style Using Linters


    1.7 Optional Exercises


    Section 2: Ensuring Correctness of Software at Scale


    2.1 Automatically Testing Software


    2.2 Scaling Up Unit Testing


    2.3 Continuous Integration for Automated Testing


    Figure 1

    Continuous Integration with GitHub Actions - Initial Build

    Figure 2

    Continuous Integration with GitHub Actions - Build Log

    Figure 3

    Continuous Integration with GitHub Actions - Build Details

    Figure 4

    Continuous Integration with GitHub Actions - Build Matrix

    2.4 Diagnosing Issues and Improving Robustness


    Figure 1

    NumPy arrays of incompatible shapes

    Figure 2

    NumPy arrays' shapes after adding a new_axis

    Figure 3

    NumPy arrays' shapes after broadcasting

    Figure 4

    Setting up test framework in PyCharm

    Figure 5

    Setting up test framework in VS Code

    Figure 6

    Setting up test framework in VS Code

    Figure 7

    Running pytest in PyCharm

    Figure 8

    Ensuring testing configurations in PyCharm are correct

    Figure 9

    Running a single test in PyCharm

    Figure 10

    Running pytest in VS Code from the Project Explorer

    Figure 11

    Running pytest in VS Code from the Test Explorer

    Figure 12

    Running individual test Test Explorer in VS Code

    Figure 13

    Setting a breakpoint in PyCharm

    Figure 14

    Debugging in PyCharm

    Figure 15

    Debugging in PyCharm

    Figure 16

    Setting a breakpoint in VS Code

    Figure 17

    Debugging in VS Code - Variable values

    Figure 18

    All tests in PyCharm are successful

    Figure 19

    All tests in VS Code are successful

    2.5 Optional Exercises for Section 2


    Section 3: Software Development as a Process


    3.1 Software Requirements


    3.2 Software Architecture and Design


    Figure 1

    Writing good code comic

    Figure 2

    Diagram showing proposed architecture of the problem

    3.3 Code Decoupling & Abstractions


    3.4 Code Refactoring


    3.5 Software Architecture Revisited


    Section 4: Collaborative Software Development for Reuse


    4.1 Developing Software In a Team: Code Review


    Figure 1

  • Create a new pull request by clicking the green New pull request button. GitHub pull requests tab

  • Figure 2

  • Click Create pull request button to open the request. Creating a new pull request.

  • Figure 3

  • Add a comment describing the nature of the changes, and then submit the pull request by clicking the Create pull request button (in the new window). Submitting a pull request.

  • Figure 4

    Adding a collaborator in GitHub

    Figure 5

    Locate up the pull request from the GitHub’s Pull Requests tab on the home page of your fellow learner’s software repository, then head to the Files changed tab on the pull request. The files changed tab of a pull request


    Figure 6

    When you find a line that you want to add a comment to, click on the blue plus (+) button next to the line. This will bring up a “Write” box to add your comment. Adding a review comment to a pull request You can also add comments referring to multiple lines by clicking the plus and dragging down over the relevant lines. If you want to make a concrete suggestion or a change to the code directly, such as renaming a variable, you can click the Add a suggestion button (which looks like a document with a plus and a minus in it). This will populate the comment with the existing code, and you can edit it to be what you think the code should be.


    Figure 7

    Note: you can only make direct code suggestions if you are a collaborator on a repository. Otherwise, you can add comments only. Adding a suggestion to a pull request GitHub will then provide a button for the code author to apply your changes directly.


    Figure 8

  • To do this, click the Finish your review button at the top of the Files changed tab. Using the finishing your review dialog In the comment box, you can add any other comments that are not associated with a specific line. For example, you can put the list of tests that you want to see added here.

  • Figure 9

  • Next you will need select to one of Comment, Approve or Request changes. Using the finishing your review dialog

  • Figure 10

  • You understand and agree with the reviewer’s comments. In this scenario, you should make the requested change to your branch (or accept the suggested change by the reviewer) and commit it. It might be helpful to add a thumbs up reaction to the comment, so the reviewer knows you have addressed it. Even better, leave a comment such as “Fixed via #commit_number” with a link to your commit that implemented the change. Responding to a review comment with an emojiResponding to a review comment with a link to commit

  • Figure 11

  • Once the reviewer approves the changes, the person whose repository it is can merge the changes onto the base branch. Typically, it is the code author’s responsibility to merge but this may differ from team to team. In our case, you will merge the changes on the PR on your repository. Merging a pull request in GitHub

  • 4.2 Preparing Software for Reuse and Release


    4.3 Packaging Code for Release and Distribution


    Section 5: Managing and Improving Software Over Its Lifetime


    5.1 Managing a Collaborative Software Project


    Figure 1

    Screenshot showing issue list tab in GitHub web interface for a repository named python-intermediate-inflammation. There are currently no issues listed and the new issue button in interface is highlighted.

    Figure 2

    Screenshot showing new issue form in GitHub web interface. The form currently has no details entered in title or comment fields with cursor currently in title field.

    Figure 3

    Screenshot of comment thread in a GitHub issue showing dropdown menu expanded for a particular comment to allow copying link to comment to reference elsewhere. Also shown and highlighted is a autolink to a particular commit hash.

    Figure 4

    Screenshot of projects tab for a GitHub user profile with new project button highlighted.

    Figure 5

  • Roadmap - suitable for a high-level visualisation of your project over time. {alt=‘Screenshot of create project pop-up window showing a grid with four featured project templates - Team planning (caption “Manage your team’s work items, plan upcoming cycles, and understand team capacity”), Future release (caption “Manage your team’s prioritized work items when planning for a feature release”), Kanban (caption “Visualize the status of your project”) and Bug tracker (“Track and triage your bugs”). In the the sidebar additional options are available to start a project from scratch using a table, board or roadmap format.’ .image-with-shadow width=“800px”} Regardless of which project type/view you select, you can easily switch to a different project layout later on.

  • Figure 6

    After it is created, you should also populate the description of the project from the project’s Settings, which can be found by clicking the ... button in the top right corner of the project. Screenshot showing how to access project board settings in GitHub. A dropdown menu has been expanded from the "Show Options" button with Settings option within this menu highlighted.Screenshot showing project settings page in GitHub. Short description field on page has had text "Tasks for the v0.1 release of the inflammation project" entered. After adding a description, select Save.


    Figure 7

    Screenshot showing default card board in GitHub. Three columns are shown headed Todo, In Progress and Done. A button to add a new task to a column is highlighted at bottom of Todo column. On the right of interface the "Actions for column" button which expands a menu from which a column can be removed and the "Add a new column to the board" (+) button which can be used to add a new column are highlighted.

    Figure 8

    Screenshot showing adding issues and notes to a project board in GitHub. The board shows three columns Todo, In Progress and Done, with three draft tasks entered into the Todo column: Finish off documenting the software; Select licence; Prepare the release notes.

    Figure 9

    Screenshot showing converting a task to issue in GitHub project interface. A draft task "Finish off documenting the software" is selected and a context menu shown with multiple options, with the first "Convert to issue" highlighted.

    Figure 10

    Finally, you can change the way you view your project by adding another view. For example, we can add a Table view to our Board view by clicking the New button and selecting it from the drop down menu. Screenshot showing how to add another project view in GitHub Project interface. A second table view of the project is shown, with two view tabs, View 1 and View 2 now present and View 2 active. The "New view" button to right of view tabs is highlighted.


    5.2 Assessing Software for Suitability and Improvement


    5.3 Software Improvement Through Feedback


    Figure 1

    Screenshot showing how to access Milestones interface in GitHub. The Issues tab for a repository is shown with Milestones button to left of New Issue button highlighted.

    Figure 2

    Screenshot showing how to create a milestone in GitHub. The Milestones view within Issues tab is shown with a message indicating no milestones have been created so far. Two buttons for creating a new milestone are highlighted.

    Figure 3

    Screenshot showing how to create a milestone in GitHub. A new milestone form is shown with three entry fields, a short text field for entering title, a date picker field for selecting due date (optional) and a long text field for entering description.

    Figure 4

    Screenshot showing how to assign an issue to a milestone. The issue list tab of a repository is shown with a single issue "Add README" selected and the Milestone dropdown on issue filter controls expanded with a list of available milestones that can be assigned to the issue shown, currently showing one milestone "Tidy up documentation".

    Wrap-up


    Figure 1

    Usefulness versus time to master grid

    Figure 2

    Overview of tools and techniques covered in the course

    Figure 3

    Overview of topics covered in the course based on level of difficulty