At the end of this lesson, you will be able to:
ensure your code follows proper style
review getting GitHub repositories from me
review saving code back to GitHub
when you create programs, you are NOT creating them just for the computer
you have 2 audiences:
computer
every other developer that has to look at your code, including you!
your program source files need to be machine and human friendly
go over style guide for TypeScript:
we will be using Google's TypeScript Style Guide
each file (like main.ts) will have a comment header like:
/* Copyright (c) 2020 MTHS All rights reserved
*
* Created by: Mr. Coxall
* Created on: Sep 2020
* This program ...
*/
also variables, function names, ... all have special rules on naming
also there are special rules on spaces, special characters, ...
we will slowly go over these in the following lessons
to commit your code, click on the "source control" button on the left hand side
when you "commit" your repo back to GitHub, a "GitHub Action" (called Mr Coxall's Super Linter!) will run and check your code to ensure it follows the rules
if you get an "error", then you must fix your code
the README.md file also needs to be updated to point to your repository and have the correct Unit name
when you paste in your code into your Google Doc, you need to "color" it with the Google Docs Add-on "Code Blocks"
yes, I actually did spell "color" correctly
in computer science we spell color like an American!
click on provided link to make new GitHub repo
call the repo: TEJ2O.1-Unit2-01
open MakeCode Micro:Bit and "import" this new repo
change the displayed text to your name
update the comment to be from you
ENUSRE you changes the name of the project as well
ENSURE you change the README.md file as well
save changes back to GitHub
ensure changes have been made
ENSURE the GitHub Action ran with no errors
see the example document to know what to submit → Jane Smith - TEJ2O - Unit2-01.pdf (see file below: ↓)
go over style guide for Python:
points to remember:
use 4 spaces per indentation level
spaces are the preferred indentation method
limit all lines to a maximum of 79 characters
comments should be complete sentences. The first word should be capitalized ...
# This is a comment.
python Docstrings need for modules, function, ...
"""
Created by: Mr. Coxall
Created on: Sept 2020
This is the "Hello, World!" module, with proper style.
"""
follow Python standard naming styles
function names should be lowercase, with words separated by underscores as necessary to improve readability
variable names follow the same convention as function names
ALWAYS use a proper name for a variable, NEVER something like "i"
ex: time_of_day
constants are all CAPS: MAX_OVERFLOW
do demo of using black
use it on all your python code to ensure you are following the rules
black --check --diff ./*.py
look for something like:
All done! ✨ 🍰 ✨
2 files would be left unchanged.
to commit your code, click the same button on the left hand side
now look at the "Mr Coxall's Super Linter" badge
it MUST be green from now on
also look at the "GitHub Actions" to see if you have any errors, and then fix them!