Skip to content

Commit d235ff5

Browse files
committed
A bit of reorg to get a java and kotlin package to match (for scope reasons), add a few blarps in the READMEs
1 parent 24dc908 commit d235ff5

File tree

10 files changed

+75
-12
lines changed

10 files changed

+75
-12
lines changed

DEMO_TALKINGPOINTS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Talking Points for meatspace demo
2+
3+
#Kotlin Overview
4+
insert a quick TLDR of kotlin here
5+
* small list of key features (java integration, android/spring, different targets (jvm/native/js), succinct, etc)
6+
7+
8+
9+
10+
* stuff final by default (requires explicit open to allow subclassing)
11+
* immutable by design
12+
* null safe by default, requires explicit definition to allow something to be null
13+
14+
# Basic Kotlin Overview
15+
[Intro To Kotlin Source](src/main/kotlin/me/kotlindemo/01_IntroToKotlin.kt)
16+
17+
Update demos to include a few more things from here. be concise, ie silly simple to keep it quick
18+
https://kotlinlang.org/docs/reference/idioms.html

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
11
# Kotlin Basics Demo
22
This is a demo of very basic kotin stuff
3+
4+
# Kotlin Overview
5+
Kotlin is a language created by Jetbrains (intellij geeks). A few years ago as it really grew in popularity, a new group
6+
called the Kotlin Foundation was created to manage the language. A bit after Google announced that kotlin was officially
7+
a supported first class language for Android development. Spring announced around the same time that they added explicit
8+
support for kotlin in spring boot 2 and spring 5 for functional programming (and included amongst other things a new
9+
Kotlin DSL for it's endpoints). Kotlin is released under the Apache 2 license
10+
11+
Some interersting links
12+
* [Evolution of kotlin, including the philosophy of kotlin's goals](https://kotlinlang.org/docs/reference/evolution/kotlin-evolution.html)
13+
* [General FAQ](https://kotlinlang.org/docs/reference/faq.html)
14+
15+
# Discussion Points
16+
## Some key points on kotlin vs java
17+
### Seamless Integration with java
18+
This was a design goal from the start. This makes it very easy to start mixing kotlin and java, simply add the dependency to
19+
gradle/maven. A very common starting point for adding Kotlin to a project is replacing DTOs and Pojos, making them actually
20+
readable (getter/setter/toString/equals/hashcode/copy are autogenerated, I will show this in a bit)
21+
22+
###
23+
24+
#Sources
25+
Some places I got ideas of things to talk about
26+
* [Kotlin doc home, with very good guides](https://kotlinlang.org/docs)
27+
* [Article on key kotlin advantages over java](https://dzone.com/articles/what-are-the-biggest-advantages-of-kotlin-over-jav)
28+
* [Play with Kotlin online without installing the dev enviornment](https://play.kotlinlang.org)
29+
* [Kotlin Koans](https://www.jetbrains.com/help/education/learner-start-guide.html?section=Kotlin%20Koans)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package me.kotlinintegration;
2+
3+
public class JavaServiceThatDoesNothing {
4+
5+
}

src/main/java/me/kotlinintegration/UseAKotlinClass.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package me.kotlinintegration;
22

3-
import me.kotlin.basic.basicstart.classes.Person;
3+
import me.kotlindemo.classes.Person;
44

55
public class UseAKotlinClass {
66
public static void main(String[] args) {
@@ -16,4 +16,9 @@ private void printADataClass() {
1616
System.out.println(" Kotlin dataclass Person toString after changing first name: " + person.toString());
1717
System.out.println(" Kotlin person explicit getter firstName: " + person.getFirstName());
1818
}
19+
20+
private void useAnExtensionFunction() {
21+
String blah = "blah";
22+
blah.doo
23+
}
1924
}

src/main/kotlin/me/kotlin/basic/basicstart/01_IntroToKotlin.kt renamed to src/main/kotlin/me/kotlindemo/01_IntroToKotlin.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.kotlin.basic.basicstart
1+
package me.kotlindemo
22

33
import java.lang.NumberFormatException
44
import kotlin.IllegalArgumentException
@@ -28,8 +28,12 @@ fun functions() {
2828
addAndPrint(14, 3)
2929
addAndPrintBody(17, 43) //cmd-click to show Unit is returned
3030
paramsWithDefaultValues() //use defaults
31-
paramsWithDefaultValues("one", false, 14)//note four is using default, declard in order without names
32-
paramsWithDefaultValues(two=false) //named params do not have to be in order
31+
paramsWithDefaultValues(
32+
"one",
33+
false,
34+
14
35+
)//note four is using default, declard in order without names
36+
paramsWithDefaultValues(two = false) //named params do not have to be in order
3337
}
3438

3539
//functions are first class and do not need to be part of a class
@@ -102,7 +106,10 @@ fun whenWithSmartCast(a: Any) =
102106
fun conditionals() {
103107
println("\n>>>> Conditionals")
104108
println(" if as an expression, max value of 8 anc 2 is ${ifAsAnExpressionMaxValue(8, 2)}")
105-
println(" if expression with blocks biggest of 13 and 53 is ${ifExpressionReturnsAValueWithBlocks(8, 2)}")
109+
println(" if expression with blocks biggest of 13 and 53 is ${ifExpressionReturnsAValueWithBlocks(
110+
8,
111+
2
112+
)}")
106113
println(" simple when as an expression ${simpleWhenAsExpression(2)}")
107114
println(" simple when as an expression out of range ${simpleWhenAsExpression(44)}")
108115
whenWithSmartCast(" smartCast with string 1")
@@ -124,7 +131,7 @@ fun progression() {
124131
}
125132

126133
fun loops() {
127-
println(">>>> Loops")
134+
println("\n>>>> Loops")
128135
simpleForLoopOverRange()
129136
progression()
130137
}

src/main/kotlin/me/kotlin/basic/basicstart/02_Collections.kt renamed to src/main/kotlin/me/kotlindemo/02_Collections.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.kotlin.basic.basicstart
1+
package me.kotlindemo
22

33
fun main() {
44
iterateCollection()

src/main/kotlin/me/kotlin/basic/basicstart/03_extensions.kt renamed to src/main/kotlin/me/kotlindemo/03_extensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.kotlin.basic.basicstart
1+
package me.kotlindemo
22

33
/**
44
* https://kotlinlang.org/docs/reference/extensions.html

src/main/kotlin/me/kotlin/basic/basicstart/classes/Classes.kt renamed to src/main/kotlin/me/kotlindemo/classes/Classes.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.kotlin.basic.basicstart.classes
1+
package me.kotlindemo.classes
22

33
/**
44
* Data classes are great for simple POJOs or DTOs, ie stuff that are simple data containers, not biz logic. You
@@ -22,7 +22,8 @@ fun main() {
2222
fun showDataClass() {
2323
val one = Person("one", "fname", "lname")
2424
val two = Person("one", "fname", "lname", 31)
25-
val three = Person(id = "one", firstName = "fname", lastName = "lname")//note use of named params
25+
val three =
26+
Person(id = "one", firstName = "fname", lastName = "lname")//note use of named params
2627
println("equals one and three: ${one.equals(two)}")
2728
println("toString: $one")
2829
println("field ${one.age}")

src/main/kotlin/me/kotlin/basic/basicstart/classes/KotlinFile.kt renamed to src/main/kotlin/me/kotlindemo/classes/KotlinFile.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.kotlin.basic.basicstart.classes
1+
package me.kotlindemo.classes
22

33
//note that this does not have to match the file path on disk
44

src/main/kotlin/me/kotlin/basic/basicstart/scopes/ScopeFunctions.kt renamed to src/main/kotlin/me/kotlindemo/scopes/ScopeFunctions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.kotlin.basic.basicstart.scopes
1+
package me.kotlindemo.scopes
22

33
/**
44
* Note that nothing is attached to a class. properties and functions are first class objects, ie do not need to be part of

0 commit comments

Comments
 (0)