As I was looking for some useful coding quotes, I discovered many funny ones. Enjoy reading them — I thought these should be compiled together.
Most are from other sources (as per linked), with the exception of a handful that are my own.
I have separated them down into:
1. The Programming Life
2. Software Engineering
3. Languages and Logic
4. Platform, Tools, and Administration
5. General
Hope you enjoy at least some of them!
In Kotlin Flow documentation, it share the 3 types of buffers, i.e. Buffer, Conflate, and CollectLatest. They allow the Kotlin Flow to emit elements before the previous one is completely processed, enabling parallelism.
The three buffers operation behave slightly differently. It took me a while to comprehend their differences. Then I realize if I analog them to one fashion adoption, then it’s simple and easy to remember too.
The Kotlin Documentation describing the Channel Pipeline by applying it to a Prime Number generator algorithm.
The code as below, concise and
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*fun main() = runBlocking {
var cur = numbersFrom(2)
repeat(10) {
val prime = cur.receive()
println(prime)
cur = filter(cur, prime)
}
coroutineContext.cancelChildren() // cancel all children to end
}fun CoroutineScope.numbersFrom(start: Int) = produce<Int> {
var x = start
while (true) send(x++) // infinite stream of integers from start
}fun CoroutineScope.filter(
numbers: ReceiveChannel<Int>, prime: Int
) = produce<Int> { for (x in numbers) if (x % prime != 0) send(x) }
The result when run, will generate the 10 prime numbers. …
The Mobile App Development Publication started back in June 2020, with the intention of having a single publication that shares mobile development across platforms (iOS, Android and others), as noted in the below article.
About slightly more than half a year by, it has grown from its infancy to more than 1000 followers today. My sincere appreciation to all following this publication, which makes the existence of the publication meaningful.
THANK YOU!
As of today, it has 333 articles within, with the home page below having Featured Articles, Latest, Trending, Android App Development, and iOS App Development. …
Kotlin Flow is one of the newest gadgets in the Kotlin language. It behave like Sequence like processing a stream of information, but with much powerful capability as shared in the below article.
Nonetheless, sequence is still a good collection feature and better than flow sometimes. Below are a few scenarios where sequence is preferred.
Flow is developed around coroutine to have its ability to perform things asynchronously, threading, parallel processing, etc.
This does come with extra cost. If we run the below with Sequence
val sequence = (1..100000000).asSequence()
val startTime = System.currentTimeMillis()
fun main() = runBlocking {
val result = sequence
.map { it * 3 }
.filter { it % 2 == 0 }
println("Start")
result
.reduce { ac, it -> ac + it }
.run { println(this) }
println("Done in ${System.currentTimeMillis() …
Sometime back, I’m curious how is List different from Sequence. I explored into it, and notice Sequence is Lazy and List is Slow. Each have their advantage.
With Kotlin Flow now in place, it behaves like a Sequence.
runBlocking {
(1..3).asSequence()
.map { println("sequence mapping $it"); it * 2 }
.first { it > 2 }
.let { println("sequence $it") }
(1..3).asFlow()
.map { println("flow mapping $it"); it * 2 }
.first { it > 2 }
.let { println("flow result $it") }
}
For the code above, both also behave like below
In the Kotlin Asynchronously Flow documentation, it shows that one can use imperative way (try-catch-finally) and declarative way (catch and onCompletion operator) to handle exception.
However, it states below.
We do not advocate for any particular approach and believe that both options are valid and should be selected according to your own preferences and code style
While the above gives one flexibility, below are my proposal with rationale given.
Shown below is a simple way of imperative way of catching exception
fun main() = runBlocking<Unit> {
try {
(1..3).asFlow().collect { value ->
check(value <= 1) { "Crash on $value" }
println("Got $value")
}
} catch (e: Throwable) {
println("Caught $e")
} finally {
println("Done")
}…
I have written step by step on setting up Charles Proxy for both iOS Simulator and Android Emulator as below
Beginning Android 11 (SDK API 30), a new security feature has been added for one to install the CA Certification before one can clearly see the data in Charles.
So to get Charles working, just follow the step as the above blog until the part where you install the certification from the chrome browser.
The certification will not be installed automatically, but instead just downloaded. If you click on the downloaded file, you’ll see as below
Most of the time, when we develop an Android App, we build Activity and Fragment. At times to set up the essential dependencies that are used across Activities, we have the Application to store them. When the application is killed, the entire app is completed it’s work.
What if we want something the still work after the application is down? There’s Service.
A
Service
is an application component that can perform long-running operations in the background
In actual fact, a service is not always run in the background. There are 3 types of services, i.e. background, foreground, and bound.
Here I just look at the background services. In particular the 3 types of services, and in terms of the lifecycle. …
One of the nice bit of Kotlin compared to Java is its ability to handle nullability. If we have a possible null code, Android Studio will error out during compile time. It is indicated clearly as shown below.
About