SShortSingh.
Back to feed

Why Kotlin Multiplatform's expect/actual Is Overused and What to Do Instead

0
·1 views

A software engineer writing for DEV Community argues that expect/actual, Kotlin Multiplatform's flagship feature for bridging common and platform-specific code, is widely misused as a default pattern by new teams. The mechanism creates compile-time, fixed bindings between common declarations and platform implementations, making it impossible to inject fakes or run unit tests in commonTest without workarounds. Drawing on experience from a project called PaymentsLab, the author found that heavy reliance on expect/actual made payment use cases untestable because no fake implementations could be substituted. The recommended alternative is to define interfaces in common code and inject platform-specific implementations via dependency injection, enabling straightforward unit testing with fakes. The author suggests reserving expect/actual only for narrow, permanent platform joints — such as type aliases for platform types — where swapping implementations is never needed.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

PostgreSQL Group Roles: Manage User Permissions in Bulk with Simple SQL

PostgreSQL group roles allow database administrators to assign and revoke permissions for multiple users simultaneously, eliminating the need to manage each account individually. A group role is created using CREATE ROLE without login privileges, while individual users are created with CREATE USER and then granted membership in the group. Permissions assigned to the group role take effect immediately for all member users, with no need to restart active sessions. Revoking a group role from a user also removes associated permissions instantly, even during an ongoing session. Administrators can query system tables with custom SQL to list all group role assignments, as no built-in directory view exists for this purpose.

0
ProgrammingDEV Community ·

Mileage Tracker App Driversnote Faces User Backlash Over Battery Drain and High Pricing

Driversnote, a mileage tracking app with nearly 3.8 million installs, automatically logs driving trips and generates IRS-compliant reports for tax deductions and reimbursements. Despite widespread praise for its near-perfect tracking accuracy, users consistently report that the app consumes 15–20% or more of daily battery life due to continuous background GPS polling. Pricing of up to $17–20 per month has drawn repeated criticism, with reviewers citing cheaper named competitors such as TripLog and MileIQ as better value. The app's free tier, capped at just 15 trips per month, has also frustrated users who feel the limit is not clearly communicated upfront. Analysts note an opportunity exists for a competing product built around battery-efficient APIs and a lower annual price point in the $20–30 range that reviewers say they would willingly pay.

0
ProgrammingDEV Community ·

How One Team Fixed Three Critical Jenkins Agent Security Flaws After Near-Miss

A software team discovered serious security gaps in their Jenkins CI/CD setup after a pull request from an external contributor briefly exposed a live network path to an internal metadata endpoint. Their core mistake was treating Jenkins agents as trusted infrastructure, when in reality agents execute arbitrary code — including from third-party contributors — and are not protected by controller-level access controls. The team had been routing both internal and untrusted fork-PR builds through the same agent pool, inadvertently giving external code access to internal deployment credentials. They had also mounted the Docker socket into agent containers for convenience, which effectively granted any running build root-level access to the underlying host machine. Following a thorough audit, the team separated build infrastructure by trust tier and moved away from docker.sock mounting to eliminate these critical attack surfaces.

0
ProgrammingDEV Community ·

Developer open-sources Kleinanzeigen's full 634-category tree after reverse-engineering it

A developer reverse-engineered the complete category structure of Kleinanzeigen.de, Germany's largest classifieds platform, after finding no public API or category reference existed. The tree spans 634 categories across three levels — 15 top-level, 143 second-level, and 476 third-level — each mapped with numeric or slug-based IDs. The dataset was compiled while building a tool called AnzeigenBoost and has now been released on GitHub under the MIT licence. The repository includes a full hierarchical tree, a flat names-only version, and a lookup code example. Contributors are welcome, as the maintainer acknowledges categories may shift over time as Kleinanzeigen updates its platform.

Why Kotlin Multiplatform's expect/actual Is Overused and What to Do Instead · ShortSingh