mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 04:58:21 +00:00
8094b54f35
Create a unified format for my wiki. Unfortunately, since most of my notes are created on a whim and I don't care much about metadata at the time, the timestamps are only approximations from my memory.
23 lines
1020 B
Org Mode
Executable File
23 lines
1020 B
Org Mode
Executable File
#+TITLE: Writing clean code
|
|
#+AUTHOR: "Gabriel Arazas"
|
|
#+EMAIL: "foo.dogsquared@gmail.com"
|
|
#+DATE: "2020-06-19 20:30:23+08:00"
|
|
#+DATE_MODIFIED: "2020-09-09 05:19:39+08:00"
|
|
#+LANGUAGE: en
|
|
#+OPTIONS: toc:t
|
|
#+PROPERTY: header-args :exports both
|
|
|
|
|
|
Code should be readable, simple, and concise.
|
|
There are a few things to consider when writing code.
|
|
|
|
- When naming stuff like variables and functions, be clear and concise.
|
|
Furthermore, if applicable, imply its type.
|
|
For example, when the variable holds an array, you can append ~_list~ to its name (e.g., ~grade_list~ vs ~grades~).
|
|
If it's a boolean, you can prepend the name with ~is_~ or ~has_~.
|
|
|
|
- Use whitespace properly and consistently.
|
|
For example, in Python, spaces are preferred to tabs and a "tab" is made up of 4 spaces following [[https://www.python.org/dev/peps/pep-0008/][PEP 8 standard]] which is a style guide for Python.
|
|
|
|
This could be inapplicable if you're worrying about how to create the code that works so be sure to apply it when refactoring.
|