UCL-RITS / rse-classwork-2020

4 stars 113 forks source link

Readability #165

Open ageorgou opened 3 years ago

ageorgou commented 3 years ago

There are many ways we can write code that produces a particular result. Often these different ways will trade off one aspect over another; for example, people sometimes choose to sacrifice readability for speed, or brevity for clarity.

For this exercise, we will focus on what makes code easier to read and maintain. Even when you have written some code yourself, it can be hard to understand it immediately if you come back to it after a long time. This can be even more difficult for those seeing the code for the first time! Many factors can affect how easy your code is to read for someone who is new to it.

The branch week09 has two short files named version1.py and version2.py, which contain some code for a hypothetical analysis. The files don't work by themselves, as they require some (fictional) libraries. Both versions do the same thing, but are written differently.

Look at the two files, then think about which one is easier to read, and why. Put your answers in the Moodle questionnaire.

twemyss commented 3 years ago

This is an interesting task, thanks.

Just to save people a few seconds of time, it looks like the files have been moved and the actual links are:

version1.py version2.py

ageorgou commented 3 years ago

Thanks for catching that, @twemyss.