When you are developing an application and aiming for testability, it’s good to have a general idea of how to define your dependencies.
The examples below will present some options on how to achieve that.
1. Dependencies that store data or an internal state
If it will hold some data or a state, it should be stored somewhere in the memory. Keeping that in mind, it’s best to implement it with a reference type, in this case, a class.
2. Dependencies that do not store data or state
If it does not hold data or state, you can use value types, i.e. structs.
Using protocols is the most common way to make something testable, extracting an interface/contract to represent the your dependency’s API. This way we can use it along with dependency injection techniques to achieve the expected testability.
This technique leverages the power of structs, representing the API as properties and setting the implementations when creating special instances of them.
Full Article: Eduardo Sanches Bocato @ Medium
Mobile App Development Trends – 29.02
Working with dates and Codable, Fun with shapes in Compose, The missing guide to deep linking and more!
The open source StarCoder 2 model runs on regular GPUs
Companies are making more and more artificial intelligence-based code generators at an astonishing rate – services like GitHub Copilot and...
Google TV updates the homescreen
You may notice your apps taking a different shape on your Google TV For You screen.
Decompose – Kotlin Multiplatform lifecycle-aware business logic components with routing and pluggable UI
Decompose is a Kotlin Multiplatform library for breaking down your code into tree-structured lifecycle-aware business logic components (aka BLoC), with...
Mobile App Development Trends – 28.02
How to use VariadicView, Comprehensive Guide To Kotlin Context Receiver, OWASP Mobile Top 10 and more!
GitHub opens access to Copilot Enterprise
Copilot Enterprise includes all the features of the existing Business plan, including intellectual property indemnification, but extends it with a...