We use privacy-friendly product analytics (no session recording, PII masked) to improve OpenStem. Load analytics? Privacy Policy
Software: explore STEM content (page 21 of 25) · openstem
Explore STEM Content
Search the community's STEM library — free to study, yours to make your own.
Software
Programming, algorithms and systems on openstem — flashcards, notes, quizzes, sketches and flowcharts shared by the community. Study free, or clone anything into your library.
When would you add a cache and what are the main invalidation strategies?1 / 9
Add a cache when reads vastly outnumber writes and slight staleness is acceptable. Strategies: write-through (cache + DB together), write-back (write cache, flush later), TTL expiry, and cache-aside (app manages cache). Invalidation is the hard part.
A bug where the program's correctness depends on the non-deterministic timing/interleaving of concurrent operations on shared mutable state — e.g. two threads incrementing a counter without synchronization can lose updates. Prevented with locks, atomics, or avoiding shared mutability.
Same Shape, Different Intent Adapter, Decorator, and Proxy all wrap one object behind an interface, which is exactly why they're easy to confuse. The difference is in what the wrapper is for: translating, extending, or controlling. A Decisi
Software
Software · L2 · Design Patterns: Which Structural Pattern?
Passing a Value Without a Fight Every time you hand a value to a function or another variable, Rust makes you pick one of three strategies. Getting this choice right up front avoids most of the borrow-checker errors newcomers run into. Work
Describe the producer-consumer pattern and its synchronization requirements.1 / 10
Producers add items to a shared buffer; consumers remove and process them. Synchronization needed: (1) mutual exclusion on the buffer, (2) consumers wait when empty, (3) producers wait when full. Typically implemented with a bounded queue + condition variables or a channel.
How is CSS specificity scored, and what beats what?1 / 10
Specificity is a tuple (inline, IDs, classes/attributes/pseudo-classes, elements). Compared left to right, a higher group wins. Inline styles outrank ID selectors, which outrank classes, which outrank type selectors.
What are the three trees Flutter maintains for rendering?1 / 10
The Widget tree (immutable config), the Element tree (mutable instances linking widgets to render objects), and the RenderObject tree (handles layout and painting).
Two Ways to Model Relationships MongoDB gives you two basic strategies for related data: embed it as a subdocument inside the parent, or store it in a separate collection and reference it by _id. There's no single right answer — it depends
Turing Machines as the Formal Model of Computation A Turing machine is M = (Q, Σ, Γ, δ, q₀, q_accept, q_reject): a finite control Q, input alphabet Σ, tape alphabet Γ ⊇ Σ ∪ {⊔}, transition function δ: Q × Γ → Q × Γ × {L, R}, start state q₀,
What is the difference between `Box<T>`, `Rc<T>`, and `Arc<T>`?1 / 10
`Box<T>` is a single-owner heap allocation. `Rc<T>` is reference-counted shared ownership for single-threaded use. `Arc<T>` is the atomic, thread-safe version of Rc for sharing across threads (slightly more overhead).
What is a window function and how does it differ from GROUP BY?1 / 9
A window function computes a value across a set of rows (the 'window') without collapsing them into one row like GROUP BY does. Each input row gets an output row. `OVER (PARTITION BY ... ORDER BY ...)` defines the window.
What is the primary benefit of moving cross-cutting network concerns into a service mesh sidecar?
AApplication code gets mTLS, retries, timeouts, and traffic shaping without implementing them itselfBIt removes the need for a network entirelyCIt eliminates the need for service-to-service authenticationDIt guarantees zero latency between services
Pure Functions and Side Effects A pure function's return value depends only on its arguments, and calling it has no observable effect beyond producing that value — no writing to a database, mutating a shared object, logging, or reading the
What is the difference between Dart's JIT and AOT compilation?1 / 10
JIT compiles at runtime (used in development for hot reload and fast iteration), while AOT compiles ahead of time to native machine code (used in release builds for fast startup and predictable performance).
ATwo threads finishing at the same timeBA bug where the outcome depends on the relative timing or interleaving of concurrent operationsCA performance optimisation that speeds up parallel codeDA deadlock involving exactly two threads
Transform, Don't Mutate JavaScript arrays ship two families of methods: ones that return a new array (map, filter, slice) and ones that mutate in place (push, splice, sort). Reaching for the non-mutating family by default keeps data flow pr