chapter one

1 Programming

 

1.1 Algorithms and Data Structures

1.1.1 Arrays vs. Linked Lists

  • An array is a collection of elements stored contiguously in memory, meaning each element is stored next to the other. There are two types of arrays to consider:
  • Fixed-size arrays: Adding one element requires recreating a whole new array by allocating a new array in memory and copying over all the elements.
  • Dynamic arrays: Many programming languages offer a more dynamic version than fixed-size arrays, for example ArrayList in Java, std::vector in C++, or slices in Go. Dynamic arrays typically allocate extra space to avoid resizing on every insertion.
  • A linked list consists of nodes where each node contains two things: some data and a pointer (also called reference) to the next node in the list. It’s important to note that linked lists have a memory overhead compared to arrays because each node needs extra space for the pointer. A specialized version of the linked list is the doubly linked list, which has pointers to both the previous and the next node.

The main differences:

1.1.2 Binary Heaps

1.1.3 Graphs

1.1.4 Topological Sort

1.1.5 Ford-Fulkerson Algorithm

1.2 Concurrency

1.2.1 Concurrency vs. Parallelism

1.2.2 Coroutines

1.2.3 Mutex vs. Semaphore

1.2.4 Data Race vs. Race Condition

1.3 Functional Programming

1.3.1 Partially Applied Functions vs. Currying

1.3.2 Functors, Applicatives, and Monads

1.4 Code Health

1.4.1 Premature Abstractions

1.4.2 You Aren’t Gonna Need It (YAGNI)

1.4.3 Focus on Product Ideas, Not Requirements

1.4.4 Cognitive Load

1.4.5 Readability

1.4.6 Simplifying Complex if Statements

1.4.7 Cohesion

1.4.8 Coupling

1.4.9 Nested Code