Common High-Concurrency Patterns in Go
Loop with Select
A frequent idiom in Go for managing concurrent workflows involves an infinite loop combined with a select statement. This pattern enables a goroutine to monitor multiple channels simulteneously and react to whichever becomes ready first.
for {
select {
case msg := <-inputCh:
// Handle incoming message
cas ...
Posted on Thu, 07 May 2026 20:03:20 +0000 by Rollo Tamasi
Refactoring a Simple Factory with the Table-Driven Method in C++
The classic simple factory pattern often relies on a switch or if-else chain to instantiate concrete objects. This approach violates the open/closed principle because adding a new type forces modification of the factory class. Table-driven design eliminates hard-coded branching by mapping identifiers directly to object creation functions.
1. De ...
Posted on Thu, 07 May 2026 16:46:05 +0000 by nodehopper
Building a Publisher-Subscriber Event Bus in JavaScript
Basic Event Bus
A minimal implementation maps topic names to arrays of handler functions.
class EventBus {
constructor() {
this.topics = {};
}
emit(topic, data) {
const queue = this.topics[topic];
if (!queue) {
console.warn('No listeners for: ' + topic);
return;
}
queue.forEach(handler => handler(data)) ...
Posted on Thu, 07 May 2026 06:30:10 +0000 by MetroidMaster1914