KotlinConf 2018 - Sealed Classes Opened My Mind: How We Use Kotlin to Tame State at Etsy by Patrick

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 28

  • @JanVladimirMostert
    @JanVladimirMostert 5 ปีที่แล้ว +17

    Thanks for the great talk!
    Will be making use of sealed classes more often after this talk

  • @edgeeffect
    @edgeeffect 2 ปีที่แล้ว +1

    I've been getting very enthusiastic about Rust recently but have been "forced" to do some Kotlin because I need an Android app and I've been finding a lot of things here that should really resonate with a Rust fan.

  • @deepakbisht7764
    @deepakbisht7764 2 ปีที่แล้ว +1

    thank you for the amazing knowledge. Great Talk!

  • @basilbourque
    @basilbourque 4 ปีที่แล้ว +3

    FYI, sealed classes are coming to Java. openjdk.java.net/jeps/360 Hopefully we'll see similar benefits in Java as discussed here.

  • @SaravanaThiyagarajs
    @SaravanaThiyagarajs 4 ปีที่แล้ว +3

    If it's too much to type, we could always use static imports. It keeps the code clean.

    • @ManpreetSingh-cs5kp
      @ManpreetSingh-cs5kp 4 ปีที่แล้ว

      Static imports work for static types ,plus static code is a big no create uncertainty in states . Ask any tester.

    • @lol-ye5lg
      @lol-ye5lg 2 ปีที่แล้ว

      @@ManpreetSingh-cs5kp A good tester accounts for that uncertainty and uses mocks?

  • @RakhiDhavale
    @RakhiDhavale 5 ปีที่แล้ว +5

    well explained ! nice talk !

  • @ryanmayobre7328
    @ryanmayobre7328 4 ปีที่แล้ว +3

    Visitor Pattern Link from Patrick's Slide: th-cam.com/video/4qLj-kSOZLQ/w-d-xo.html

  • @rajushingadiya2860
    @rajushingadiya2860 5 ปีที่แล้ว +6

    Nice ppt with funny stuff

  • @PandukaDeSilva
    @PandukaDeSilva 5 ปีที่แล้ว +4

    Great talk! but just want to clarify, 'when' expression should not always be exhaustive unless it's in a return expression. There will be just a warning instead

  • @Alberto_Cavalcante
    @Alberto_Cavalcante 3 ปีที่แล้ว

    Nice talk

  • @HendraWijayaDjiono
    @HendraWijayaDjiono 4 ปีที่แล้ว +1

    When I'm trying to replicate the Cancelled object inside of sealed class Result, I can't use `is` inside of the when branch
    val done = when (result) {
    is Result.Success -> showList(result.items)
    is Result.Failure -> result.error.printStackTrace()
    Result.Cancelled -> hideStuff()
    }

  • @thamidudharshitha5515
    @thamidudharshitha5515 3 ปีที่แล้ว +3

    Great presentation. I enjoyed alot. But the audience is some bunch of robots with 0 humor. When Patrik try to crack a joke, audience is like (O-O). Then he explains that it is a joke. Feels bad man.

  • @sagarock1012
    @sagarock1012 4 ปีที่แล้ว +1

    @0:07 I thought i am watching flutter conf : xD

  • @MrGarkin
    @MrGarkin 3 ปีที่แล้ว

    Ocaml like pattern matching and union types are very cool concept.
    But sealed class conditionals have terrible performance because they use javas `instanceof` under the hood.

    • @MrGarkin
      @MrGarkin 3 ปีที่แล้ว +1

      It should be trivial to implement compile time plugin to generate hashed constant per sealed class and compare those instead.

  • @HendraWijayaDjiono
    @HendraWijayaDjiono 4 ปีที่แล้ว +1

    12:02 I tested and it does work though

  • @ChrisAthanas
    @ChrisAthanas 3 ปีที่แล้ว +1

    Ah Um ah um ah um ah um

  • @PaulSebastianM
    @PaulSebastianM 6 ปีที่แล้ว +2

    Kotlin's `when is` -> Rust's `match`
    Kotlin's `sealed class` -> Rust's `enum` (or `struct` or `Either`)
    Now which is more ergonomic? Which is easier to write? Which is easier to develop in? I'd like to think that it's a tie but I'm leaning towards Rust for some odd reason.

    • @thompson4822
      @thompson4822 6 ปีที่แล้ว +1

      There is little mystery as to why you would prefer Rust. It is what you are already familiar with. Kotlin also has the notions of enum, struct, either, etc.
      As far as ergonomics, expression, and ease of development, I would say this is going to be a judgement call. Personally I like the addition of the word 'is' to the switch/case mechanism, as I think this makes things more legible. I can't find myself caring too much about having to type 'sealed', because the infrequency of doing so is never going to cause me to bat an eye. But again, these sorts of things are subjective - if you like Rust's syntax better, develop the next amazing Rust application.

  • @bocckoka
    @bocckoka 3 ปีที่แล้ว +1

    to me these sealed classes look like an ugly syntax for sum types

  • @ForCeGR
    @ForCeGR 4 ปีที่แล้ว

    jokes

  • @nyarian835
    @nyarian835 5 ปีที่แล้ว +2

    "No need for polymorphism" - sure, object-oriented programming is dead in android, no need for this.

  • @amanchhabra1161
    @amanchhabra1161 5 ปีที่แล้ว +2

    content is good but need a better speaker

    • @9rh9
      @9rh9 4 ปีที่แล้ว +8

      AMAN JAIN Speaker is good but needs a better crowd.