109: Learning Kotlin – Sequences the new Iterables

In this episode of Fragmented, we go back to learning some Kotlin and look at the Iterable like data structure introduced called “Sequences”. What is a sequence? How is it different from Iterable? When should I use it?

Download directly

Show Notes

Eager/Lazy

Eager evaluation:

val lst = listOf(1, 2)
val lstMapped: List<Int> = lst.map { print("$it "); it * it }
print("before sum ")
val sum = lstMapped.sum()

// prints "1 2 before sum"

Lazy evaluation:

val seq = sequenceOf(1, 2)
val seqMapped: Sequence<Int> = seq.map { print("$it "); it * it }
print("before sum ")
val sum = seqMapped.sum()

// prints "before sum 1 2"

Source stackoverflow.com answer

Intermediate and terminal operations

Notice that at each chain operation, a new temporary list is created:

data class Person(val name: String, val age: Int)

fun main(args: Array<String>) {
    val people = 
        listOf(Person("Chris Martin", 31), 
               Person("Will Champion", 32),
               Person("Jonny Buckland", 33),
               Person("Guy Berryman", 34),
               Person("Mhris Cartin", 30))

    println(people
            .filter { it.age > 30 } // new temp. list
            .map {                  
                it.name.split(" ").map {it[0]}.joinToString("")
            }  // new temp. list
            .map { it.toUpperCase() }) // new temp. list
}

Using a sequence:

println(people
        .asSequence()  // convert to sequence
        .filter { it.age > 30 } // lazy eval (intermediate op)
        .map {                  
            it.name.split(" ").map {it[0]}.joinToString("")
        }  // lazy eval (intermediate op)
        .map { it.toUpperCase() }  // lazy eval (intermediate op)
        .toList() // terminal operation
       )

Without a terminal operation, Sequences won’t print anything:

val seq = sequenceOf(1, 2, 3)
println(seq) // prints address
println(seq.toList()) // [1, 2, 3]

You can’t pick an index from a sequence:

println(seq[0]) // throws ERROR "No get method providing array access"
println(seq.toList()[0]) // 1

Sponsors

Contact

108: State of React Native for Android with Ryan Salva

In this episode Donn talks to React Native magician Ryan Salva. React native and cross-platform development is typically one of our most requested topics so we kick the new year off with React Native. Ryan and Donn dive into the state of React Native today for mobile development, how it’s matured since inception, what kinds of apps are suited to be built with React Native, what kinds aren’t, what are the benefits to using React Native, some tips like pushing updates without having to upload to the play store every time and so much more.

Listen on!

Download directly

Show Notes

Misc

Noteworthy quotes from this episode:

As developers, we are empowered to break things; it’s our god given right!

.

Javascript is a beautiful disaster

Sponsors

Contact

107: Shape shifting SVGs with Alex Lockwood

In this episode, we talk to Alex Lockwood who created shapeshifter.design, while at Google. Shape Shifter is an amazing tool that can help developers create Animated Vector Drawables without losing all their hair. Think of shapeshifter as a developer-friendly, open source, After Effects alternative for Android developers.

Alex talks to us about how and why he created Shape Shifter, the different tools that have evolved out of its creation and just getting a good grasp of its working.

Download directly

Show Notes

Abt Alex Lockwood

Shape Shifter

SVGO

Shape Shifting & Icon animations

Sponsors

Thanks to Buddybuild for sponsoring this episode of Fragmented! Ship apps faster with BuddyBuild 🚀 Give them a try for free at fragmentedpodcast.com/buddybuild.

Contact

106: The Reactive Workflow Pattern with Ray Ryan

In this episode, we sit down and talk to Ray Ryan from Square about the Reactive Workflow pattern that he recently gave a talk on. This pattern goes deep into RootViews, containers, ViewFactories and much much more.

Download

Show Notes

Sponsors

Contact

105: Jake Wharton on the Android Kotlin Guides

In this episode, we talk to Jake Wharton of Google on a recent Kotlin coding style guide that they released: the Android Kotlin Guides. In this episode, we pick his brains and ask him how he structured the guide, how he partitioned it to fit some of the idiosyncrasies of Kotlin, what some of the challenges were, when coming up with the guide and much more.

Jake’s one of the best out there and it’s always such a pleasure to have him on the show.

Download directly

Show Notes

The style guides

Building the style guide

Android Kotlin Guides

Mockito when problems:

Misc

Contributing

Sponsors

Contact