Niektóre rzeczy trzeba dobrze przyprawić żeby były lepsze ... tak samo jest z pisaniem aplikacji na Androida. Jako programiści zaczynamy mieć czasami dość Javy i chcielibyśmy się przerzucić na coś lepszego i czytelniejszego. Takim rozwiązaniem może okazać się Kotlin. O zaletach języka i o tym jak może ułatwić pracę z Androidem dowiecie się podczas tego wykładu.
5. Frist Law of Software Quality
E=mc2
Error=(more code)2
6.
7.
8. otlin
• created by JetBrains
• open sourced :)
• statically typed programming language
• runs on JVM
• can be compiled to JavaScript source code
• works on Spring Boot
14. Lambdas
val sum: (Int, Int) -> Int = {x: Int, y: Int -> x+y}
val sum = {x: Int, y: Int -> x + y}
fun apply(i: Int, f: (Int) -> Int) = f(i)
apply(9, {x -> x + 60})
apply(9) {x -> x + 60}
29. Write executable specifications
@Test
public void testCalculateTaxRate() {
TaxRateCalc calculator = new TaxRateCalc();
Integer value = calculator.calculateRate(200, 10);
assertEquals(300,value);
}
30. Write executable specifications
class TaxCalculatorSpecs: Spek() { init {
given("Tax rate calculator with default locale settings") {
val taxRateCalc = TaxRateCalc ()
on("calculating the rate for an income of 200 and an average
change of 10 per semester") {
val value = taxRateCalculator.calculateRate(200, 10)
it("should result in a value of 300") {
assertEquals(300, value)
}
}
}
}}
31. Library Jar Size Dex Size Method Count Field Count
kotlin-runtime-0.10.195 354 KB 282 KB 1071 391
kotlin-stdlib-0.10.195 541 KB 835 KB 5508 458
Library Jar Size Dex Size Method Count Field Count
scala-library-2.11.5 5.3 MB 4.9 MB 50801 5820
groovy-2.4.0-grooid 4.5 MB 4.5 MB 29636 8069
guava-18.0 2.2 MB 1.8 MB 14833 3343
Source: Using Project Kotlin for Android by Jake Wharton