Software Development Reference

Kip Landergren

(Updated: )

My cheat sheet for software development covering basic understanding, terminology, and workflows.

Contents

Hash Functions

h: 2n → 2k

Generally:

Non-exhaustive list of desirable properties, depending on the application:

Applications:

Cryptographic Hash Functions

SHA-1

$ echo -n 'hello world' | sha1sum
2aae6c35c94fcfb415dbe95f408b9ce91ee846ed  -
$ echo -n 'hello world!' | sha1sum
430ce34d020724ed75a196dfc2ad67c77772d169  -

Booleans

0 false
1 true

Beware! Unix command exit codes are:

0 success
1 error

Numeral Systems

Positional Notation

ijkradix ⇒ (i × radix2) + (j × radix1) + (k × radix0)

Binary - Base 2

bit contraction of “binary digit”
1012 ⇒ (1 × 22) + (0 × 21) + (1 × 20)
0000 0
1111 15

Octal - Base 8

1018 ⇒ (1 × 82) + (0 × 81) + (1 × 80)

Hexadecimal - Base 16

10116 ⇒ (1 × 162) + (0 × 161) + (1 × 160)
Hex value Decimal Value
00 0
FF 255

Conversions

Decimal Binary Octal Hexadecimal
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F

Powers of 2

20 1
21 2
22 4
23 8
24 16
25 32
26 64
27 128
28 256
29 512
210 1024
211 2048
212 4096
216 65,536
232 4,294,967,296
264 18,446,744,073,709,551,616

Powers of 10

100 1
101 10
102 100
103 1000
104 10,000
105 100,000
106 1,000,000
107 10,000,000
108 100,000,000
109 1,000,000,000
1010 10,000,000,000

Units

byte 8 bits (most common)
nibble 4 bits; a play on words in that “a nibble is a portion of a bite (byte)”
word the natural unit of data for a processor

Why 8 bits to a byte?

Convenience given that 8 is 23 and history with 7-bit ascii.

Bit Shifting

For int-like types, left bit shifting by n multiplies the value by 2n :

10 << 1 # 10 * 2^1 = 20
10 << 2 # 10 * 2^2 = 40
10 << 3 # 10 * 2^3 = 80
10 << 4 # 10 * 2^4 = 160

Encoding

ASCII

Permission Bits

rwx 7 read, write, and execute
rw- 6 read and write
r-x 5 read and execute
r-- 4 read
-wx 3 write and execute
-w- 2 write
--x 1 execute
--- 0 no permissions
permission octal field
rwx------ 0700 user
---rwx--- 0070 group
------rwx 0007 other

Selected common permissions:

0777 rwxrwxrwx everyone rwx
0755 rwxr-xr-x owner rwx, everyone else r-x
0655 rw-r-xr-x owner rw-, everyone else r-x
0644 rw-r--r-- owner rw-, everyone else r--

Directory permissions have special meanings:

This StackOverflow answer goes into more detail.

Software Development Terminology

abstraction
the separation of the use from the implementation
angle brackets
< >
backtick (diacritical mark term: grave accent)
^
braces (AKA “curly braces”, “curly brackets”, “moustache brackets”)
{ }
brackets (AKA “square brackets”)
[ ]
caret
the text cursor
caret (diacritical mark term: circumflex)
^
declarative programming
code style that expresses logic without specifying control flow
dynamic programming language
a programming language that defers certain programming behaviors until runtime; not to be confused with a dynamically typed language
functional programming
programs constructed by the application and composition of functions
imperative programming
code style that expresses desired changes in program state
paradigm
the classification of a programming language according to its features; e.g. “functional”
parens
( )
peek
return value at location; could be by index (e.g. an array) or by operation (e.g. via top on a stack)
robustness
the likelihood that small changes in a specification will require correspondingly small changes in the program
runtime configuration / feature flags
the ability to modify settings and behavior for live traffic and usage
static programming language
a programming language that performs certain programming behaviors at compilation time
stream
a sequence of data objects
telemetry
timing data
transpiler
a source-to-source converter; a type of compiler

Git Workflows

Fork and Pull / Integration Manager / Integrator

Contributors do not (necessarily) have commit access to a repository and instead fork it to create their own copy, work within that forked version, and communicate to the original repo’s maintainer (possibly through pull requests) that their forked repository’s branch has contributions ready for pulling and merging into the original repository.

Centralized / Shared Repository

Multiple contributors have commit access to a repository and work on clones of it.

git-flow

Useful for:

Consider alternatives if:

GitHub Flow

Useful for:

Consider alternatives if:

Others

Versioning

For Libraries

Recognize:

Preferred versioning policy:

Strive for:

For Applications

Recognize:

Strive for:

Best Practices

Recognize:

Strive for:

Consider:

Schemes

Semantic Versioning (SemVer) MAJOR.MINOR.PATCH, where MAJOR is breaking backward-compatibility, MINOR is additive, backwards-compatible changes, and PATCH is backwards-compatible bugfixes
Semantic Import Versioning Go’s approach of encouraging libraries to follow SemVer with the added requirement that the import path must be file-local to its use and scoped to the major version
Calendar Versioning (CalVer) versioning convention based on project release calendar; no hard and fast rules
Serial Versioning each version is an increment of the previous

Software Versioning Terminology

bug-for-bug compatibility
preserving aberrant behavior in new implementations to not disrupt compatibility with consumers
dependency hell
the frustration from problems involved in managing software dependencies; Dependency hell Wikipedia article
diamond dependency
a problem where two dependencies have sub-dependency version conflicts
evergreen software
constantly updated software, possibly without user control
transitive dependency
a sub-dependency not directly referenced or used by the grandparent
upgrade cliff
releasing beta or early access APIs to versions so that libraries can support multiple versions

Additional Resources

Formatting

elisp Formatting

Times and Dates

Format strings, for use with format-time-string:

%F the ISO 8601 date format: 2006-01-02
%R synonym for %H:%M: 15:04

Examples:

(format-time-string "%F @ %R %z" (date-to-time "02 Jan 06 15:04 MST") "MST")
"2006-01-02 @ 15:04 -0700"

(format-time-string "%Y-W%W %a %b %d" (date-to-time "02 Jan 06 15:04 MST") "MST")
"2006-W01 Mon Jan 02"

Code Review

Gerrit

Resources

Networking

OSI Model

OSI Model Wikipedia article

Layer 7 L7 Application Layer
Layer 6 L6 Presentation Layer
Layer 5 L5 Session Layer
Layer 4 L4 Transport Layer
Layer 3 L3 Network Layer
Layer 2 L2 Data Link Layer
Layer 1 L1 Physical Layer

Data Structures

Array

For dynamic (growable) arrays:

access O(1)
mutate (at beginning) O(n)
mutate (at middle) O(n)
mutate (at end) O(1)

Computational Complexity

Algorithms

Graph Traversal

FAQ

How to handle validating state?

Scenario:

An object exists, and its state is valid. An object is modified, is its state valid?

The questions arise:

This leads to an alternative path:

Create an immutable object which validates its state on construction, failing to create the object if invalid.

What does the “rc” of files like .bashrc mean?

The “rc” suffix stands for “run commands”.