Skip to content

Archive / page 46

All articles

Every practical article from the Nalar archive, newest first.

Software Engineering 11 Sep 2026 9 min read

Parameterize from Above: Make Dependencies Explicit

Parameterize from Above: Make Dependencies Explicit A method can look self-contained while quietly deciding which clock, repository, client, or filesystem implementation the application must use. That hidden construction becomes painful when a test needs a controlled collaborator or production needs a different implementation. Parameterize from Above is a small design move: instead of constructing a dependency inside the code that uses it, accept that dependency from a caller at a higher level. The caller becomes responsible for choosing and constructing the collaborator.

Software Engineering 11 Sep 2026 9 min read

Mutation Testing: Check Whether Tests Detect Broken Behavior

Mutation Testing: Check Whether Tests Detect Broken Behavior A test suite can execute every line of a function and still miss a defect. The tests may call the right code but make weak assertions, cover only one outcome, or never check a boundary condition. Mutation testing probes that gap by making small changes to production code and running the relevant tests against each changed version. If a test fails, the change is said to be killed. If all tests still pass, the mutation survives and deserves inspection.

Software Engineering 11 Sep 2026 7 min read

Middle Man Code Smell: Remove Delegation That Adds No Value

Middle Man Code Smell: Remove Delegation That Adds No Value Delegation is useful when one object asks another object to do work. It can separate responsibilities and keep implementation details behind a boundary. But delegation can become ceremony when an object does little more than forward most calls to another object. That situation is commonly called the Middle Man code smell. The extra layer adds names, files, navigation, and maintenance work without owning a meaningful decision.

Cybersecurity 11 Sep 2026 9 min read

Manage Concurrent Sessions Without Breaking Legitimate Use

A user signs in on a laptop, then on a phone, and later on a work computer. All three sessions may be legitimate. If one device is lost or a session token is stolen, though, the same account can also have a session the user no longer controls. A simple rule such as “allow only one login at a time” looks like a security control, but it mixes two different questions: how many sessions exist, and whether each session is still trustworthy. Strict concurrency limits can disrupt legitimate users while doing little to identify the session that actually needs to be removed.

Artificial Intelligence 11 Sep 2026 11 min read

Let Classifiers Abstain with Selective Prediction

Let Classifiers Abstain with Selective Prediction A classifier does not have to answer every case. In many systems, forcing a prediction on an ambiguous input is worse than sending that input to a human, requesting more information, or falling back to a safer workflow. Selective prediction gives a model that option. The classifier produces its usual prediction, but the system accepts it only when a selection rule considers the case reliable enough. Otherwise, the system abstains.

Cybersecurity 11 Sep 2026 9 min read

Keep Untrusted Data from Forging Log Entries

Security logs are useful only when their records mean what investigators and monitoring systems think they mean. A login failure, permission change, or rejected request may contain values supplied by a client. If an application simply joins those values into a line of log text, special characters can blur the boundary between the application’s event and the data inside it. That problem is called log injection or log forging. The defensive goal isn’t to remove every unusual character from user input. It is to make sure untrusted data remains data when it reaches the logging format. This article develops that mental model, shows why structured logging helps, and explains what still needs attention after the event boundary is protected.

Cybersecurity 11 Sep 2026 9 min read

Keep TLS Certificate Verification Enabled

An HTTPS client does more than encrypt bytes. During the TLS handshake, it also checks evidence about the server’s identity. If application code disables those checks, the connection can remain encrypted while being connected to an unintended endpoint. That distinction is central to secure TLS use. Encryption protects data against passive observation, but authenticated encryption to the wrong peer does not establish the identity the application intended to contact. The practical rule is: keep certificate-chain and hostname verification enabled, and repair trust configuration instead of bypassing verification.

Cybersecurity 11 Sep 2026 9 min read

Keep Bearer Tokens Out of URLs

A bearer token grants access to whoever presents it successfully. That makes its storage and transport path part of the authentication design. If an application places such a token in a URL, the credential can travel into systems that were built to record or process URLs rather than protect secrets. The immediate request may still use HTTPS. The problem is what happens around that request: server access logs, reverse proxies, monitoring tools, browser history, support captures, and analytics pipelines can all handle URL data. A token copied into those places gains more exposure paths and can remain there long after the request finishes.

Go 11 Sep 2026 5 min read

Iterate Go Map Values with maps.Values

Sometimes a Go map’s keys are irrelevant to the next operation. You may need to total counters, inspect status values, or pass the values into an iterator-aware helper. A plain map range works well inside one loop, but it doesn’t give you a value sequence that can cross an API boundary. Since Go 1.23, maps.Values returns an iter.Seq over a map’s values. That lets code consume values directly and postpone slice allocation until a later operation actually needs a slice.

Go 11 Sep 2026 4 min read

Iterate Go Map Pairs with maps.All

A normal range loop is often the clearest way to walk through a Go map. The situation changes when another API expects an iterator rather than a map. Starting in Go 1.23, maps.All provides that bridge by exposing a map’s key-value pairs as an iter.Seq2. maps.All doesn’t copy the map into a slice or build a second map. It returns an iterator that can feed a range loop or another iterator-aware function. The main constraint is familiar from map iteration: pair order is unspecified.

Go 11 Sep 2026 5 min read

Iterate Go Map Keys with maps.Keys

Sometimes you need only the keys from a Go map. A plain range loop handles that case well, but an iterator becomes useful when the keys need to flow into another iterator-aware API or when a function should expose keys without first allocating a slice. Since Go 1.23, maps.Keys returns an iter.Seq over a map’s keys. You can range over it directly, stop early, or pass it to helpers such as slices.Sorted and slices.Collect.

Go 11 Sep 2026 5 min read

Insert Values into Go Slices with slices.Insert

Adding a value to the middle of a Go slice takes more work than appending at the end. Elements after the insertion point need to move, and the operation may require a larger backing array. slices.Insert packages that splice into one standard-library call. The function accepts a slice, an index, and one or more values. It returns the resulting slice, so the usual form assigns that result back to the slice variable.

Software Engineering 11 Sep 2026 8 min read

Humble Object Pattern for Hard-to-Test Boundaries

Humble Object Pattern for Hard-to-Test Boundaries Some code is difficult to test for reasons that have little to do with its business rules. A screen handler may depend on a UI framework. A file watcher may need operating-system events. A scheduled job may be invoked by infrastructure that is awkward to reproduce in a unit test. A common mistake is to put more logic inside that difficult boundary. Tests then need the framework, filesystem, clock, process, or device just to check an ordinary decision.

Tech 11 Sep 2026 9 min read

How Wi-Fi Roaming Switches Between Access Points

A home can have several Wi-Fi access points yet still present one familiar network name. As you walk from one room to another, your phone or laptop may leave one access point and connect to another without asking you to select the network again. That movement is called Wi-Fi roaming. It sounds as if the router simply passes the device to the next access point, but the device itself has a major role in deciding when to move. That detail explains a common frustration: a nearby access point can have a strong signal while a phone remains attached to a weaker one farther away.

Tech 11 Sep 2026 7 min read

How USB-C Chargers Negotiate Power

A 100-watt USB-C charger does not normally push 100 watts into every device connected to it. A phone may take far less, while a laptop can request much more. The number printed on the charger describes what it can provide under supported conditions, not a fixed amount that every connected device must accept. That distinction makes USB-C charging easier to reason about. The charger, device, cable, and supported charging method all take part in determining the usable power. Once those pieces are separated, common questions about oversized chargers, slow charging, and cable choice become much clearer.

Tech 11 Sep 2026 8 min read

How Screen Refresh Rate Affects Motion and Battery Use

A phone or laptop screen advertised as 90 Hz or 120 Hz can look noticeably smoother than a 60 Hz screen, especially while scrolling. Yet a higher number does not make every video sharper, every application quicker, or every game run at the same rate. The key is to separate refresh rate from the content being shown. Refresh rate describes how often the display can update its image. The content has its own rate at which new frames become available. Those two rates interact, but they are not the same thing.

Tech 11 Sep 2026 8 min read

How Pocket Detection Prevents Accidental Phone Touches

A phone in a pocket can experience many of the same things as a phone in your hand: movement, pressure against the screen, and occasional taps from fabric or other objects. Yet many phones can reduce accidental screen input while they are covered or tucked away. This behavior is often called pocket detection, pocket mode, or a similar name. It is not one universal feature with one fixed design. Phone makers can combine sensor readings, touchscreen data, device state, and software rules in different ways.

Tech Updated 15 Sep 2026 9 min read

How Auracast Bluetooth Audio Broadcasting Works

Most Bluetooth audio feels like a private connection: pair a phone with a pair of earbuds, then the phone sends sound to that accessory. That model works well for one listener, but it becomes awkward when many people want to hear the same source. Auracast broadcast audio uses a different model. A compatible transmitter can broadcast Bluetooth audio that multiple nearby compatible receivers can join. The transmitter does not need to create a separate one-to-one audio connection for every listener.

Artificial Intelligence 11 Sep 2026 10 min read

Fuse Keyword and Vector Search with Reciprocal Rank Fusion

Fuse Keyword and Vector Search with Reciprocal Rank Fusion A RAG system often needs two kinds of retrieval at once. Keyword search is good at exact strings such as product codes, error messages, and names. Vector search can recover passages that express the same idea with different words. Running both is easy; combining their scores correctly is where many implementations become fragile. Reciprocal rank fusion (RRF) solves that problem by ignoring raw scores and combining rank positions instead. BM25 and vector similarity do not share a stable numeric scale. The sections below calculate RRF on a small example, then cover the parameters and evaluation checks that matter in hybrid retrieval.

Artificial Intelligence 11 Sep 2026 9 min read

Focus Classifier Training with Focal Loss

Focus Classifier Training with Focal Loss A classifier can spend much of its training signal on examples it already handles correctly. This becomes especially troublesome when easy examples vastly outnumber difficult ones. A detector, for instance, may encounter many obvious background locations for every location containing an object. Focal loss changes the contribution of each example according to the model’s confidence in the correct class. Easy, high-confidence examples receive less weight. Harder examples retain more of their cross-entropy loss. The mechanism is small, but using it well requires understanding what it changes and what it doesn’t.

Go 11 Sep 2026 5 min read

Find the Smallest Go Slice Value with slices.Min

Finding the smallest value in a Go slice doesn’t require sorting or a hand-written comparison loop. When the element type has a natural order, slices.Min states the operation directly and leaves the input untouched. The call is compact, but its contract matters at the edges. An empty slice causes a panic, and a floating-point NaN propagates to the result. Those cases are best handled where the application can attach useful meaning to them.

Go 11 Sep 2026 5 min read

Find the Largest Go Slice Value with slices.Max

Finding the largest value in a slice is a small operation, but handwritten loops still create room for awkward initialization and missed empty-input handling. For ordered values such as integers, strings, and floating-point numbers, slices.Max expresses the operation directly. The function scans the slice and returns its maximal element. It doesn’t sort or modify the input. Two details deserve attention in production code: an empty slice causes a panic, and floating-point input containing a NaN produces a NaN result.

Go 11 Sep 2026 5 min read

Find Minimum Struct Values in Go with slices.MinFunc

Finding the smallest number in a slice is straightforward, but real programs often need the cheapest quote, earliest task, shortest route, or lowest-priority struct. Those values aren’t ordered by Go itself, so slices.Min can’t express the rule. slices.MinFunc handles that case. You provide the slice and a comparator; it returns the element that is minimal according to that comparator. What slices.MinFunc does The function accepts slices of any element type:

Go 11 Sep 2026 5 min read

Find Maximum Struct Values in Go with slices.MaxFunc

Finding the largest integer in a Go slice is easy. The problem gets more interesting when the slice contains structs and “largest” means the build with the longest duration, the newest release, or the highest application-specific score. slices.MaxFunc is designed for that case. It scans a slice and returns the maximal element according to a comparator you provide, so the ordering rule can live next to the selection instead of being hidden in a separate sort.