[VDZ22] 9 Java Patterns that Kotlin made obsolete by Sebastian Brunner

Ғылым және технология

Are you a Kotlin expert? Or maybe you have never worked with it before?
Either way, there’s a lot for you to learn because Kotlin isn’t just a fancy, new Java syntax, but another way of programming!
Come with me on a quick journey comparing Java’s beloved design patterns and how they were simplified or even replaced by Kotlin quirks and features.
Amongst those patterns are Singleton, Factory, Builder, Util and more. Even if you’re not interested in patterns, you can still learn about the features of Kotlin like extension properties or delegates. There’s something new for everyone.

Пікірлер: 42

  • @aortizc82
    @aortizc826 ай бұрын

    Straight to the point, easy to remember, easy to apply IRL. 😊

  • @MrKenalik
    @MrKenalik2 жыл бұрын

    I was so excited after the first "takeaway" and started thinking that I need to watch the video to the end and then later to show it somebody else to discuss. Compile time error NPE check is really strong feature. I think in java it can be done by extending the pom.xml with some extra plugins (I am pretty sure). I would really like to have it built in. Others "takeaways" are more like a syntax sugar or features that incline you, or even forgive you when you write poorly designed code (I mean the method overloading + default values). I don't want to offend some touchy software engineers but I see only one strong argument here (takeaway#1) and I don't see how it convinces the "business" to start using it. I am talking only about enterprise level java I am not sure how it works in android world. Thanks author anyway!

  • @Seppjos

    @Seppjos

    2 жыл бұрын

    Hi and thanks for the feedback! I guess I set the bar too high with the first takeaway and it is of course Kotlin's main selling point over Java (especially to the business). However, from my experience devs tend to underestimate the power and fun that comes from this syntax sugar. It's just more fun to code in Kotlin than Java and it opens up and provides more freedom to developers. I've had great success convincing the business (in a big bank) to switch to Kotlin by mentioning that it's interoperable with Java so you don't need to rewrite all the code at once. Of course Kotlin has many more feature that unfortunately did not fit into my 20 min talk ;)

  • @mattdoestechstuff

    @mattdoestechstuff

    2 жыл бұрын

    @@Seppjos This is exactly what I did too at my work too when convincing them to move to Kotlin (I work in a big Bank too in Australia). All business wants to hear is that developers prefer it, that it's interoperable with Java and that it will reduce development time.

  • @Qrzychu92

    @Qrzychu92

    10 ай бұрын

    I am a C# programmer, but this looks WAY better than Java. Saying "it's just syntactic sugar" is like saying tha async/await is only sugar - which in reality it is just that, but it is SO MUCH better than callbacks. Embrace Kotlin, seems like a great lnaguage to work in!

  • @deepakbisht4957

    @deepakbisht4957

    6 ай бұрын

    ​@@Qrzychu92 Exactly! I like java hut I'm not right like some java and ja fanboys. Around 2018 when I started using Kotlin in my Android project it say immediate changes the code readability and concise Kotlin syntax. The sugarcoat thse java fanboys talk about is actually kotlin frontend in it's syntax and it made it that way to concise things and make code more readable. Now I'm using Kotlin In Spring boot project and so far it's a wonderful experience... Java developers don't need to hate kotlin because it's just better java. I myself defend java when js developer don't understand Java design principles, OOPs & SOLID principles but I don't blindly say java is good with everything...

  • @bizoitz86
    @bizoitz862 жыл бұрын

    I wonder what “looking OO (Object-Oriented)” means.

  • @zerettino
    @zerettino Жыл бұрын

    #8 is not a good example in my opinion : when you read "four < five" you don't what the comparison is based on. To understand what is going on, you have to read all the code to see where "compareTo" is defined. "four.releasedBefore(five)" would be a much better way to write this so that it's easier for the reader to understand.

  • @vladimirkraus1438

    @vladimirkraus1438

    3 ай бұрын

    yeah, the example was not the best one. but i guess this was just to illustrate the feature.

  • @donwald3436
    @donwald3436 Жыл бұрын

    Optional is even funnier becauses it causes NullPointerException as well as ArrayIndexOutOfBoundsException.

  • @mattdoestechstuff
    @mattdoestechstuff2 жыл бұрын

    Fantastic talk 👏 This is now going to be one of my go to videos when training the Java Devs in Kotlin at work!

  • @kqvanity
    @kqvanity3 ай бұрын

    18:24 I"ve indeed come across snippets/repos out there that still write them manually in Kotlin, with lots of clout, because, well, it was aesthetically highlighted

  • @jordan7831
    @jordan78312 жыл бұрын

    Why Kotlin users always spit on Java ? Just move on, and appreciate Kotlin features

  • @HerbertLandei

    @HerbertLandei

    7 ай бұрын

    That's just our PTSD speaking, which kicks in once you overcome the Stockholm syndrome.

  • @deepakbisht4957

    @deepakbisht4957

    6 ай бұрын

    Bruh this love for the language is everywhere 🤦. JS developers are also lole that. Why can't you simple use everything it's not hard to code in these languages. Just use things what works best for the current solution instead of favouring any language...

  • @HerbertLandei

    @HerbertLandei

    6 ай бұрын

    @@deepakbisht4957 There are examples where one language is at least as good as another one in every regard. Kotlin is as good as Java or better in all regards, TypeScript is superior to JavaScript. There are silly language wars like C# vs Java, where it's not clear which one is better, but in some cases it just is.

  • @kqvanity

    @kqvanity

    3 ай бұрын

    Any superset technology has to be mentioned with respect to its now-inferior predecessor.

  • @thilankaliyanaarachchi984
    @thilankaliyanaarachchi9844 күн бұрын

    Java version of factory method expresses the programmers intention clearly than the Kotlin version

  • @SirWolf2018
    @SirWolf20182 жыл бұрын

    Spring has recently released `andExpectAll` for its `ResultActions` API, so it's slightly less annoying now to make sure all assertions are reported when at least one fails.

  • @fabricioaraujo7642
    @fabricioaraujo7642 Жыл бұрын

    So kotlin is basically a scala with a good marketing...

  • @deepakbisht4957

    @deepakbisht4957

    6 ай бұрын

    Nope it's a programming with fun. Best for the java developers. They don't need to hate kotlin. They should just try to use it...

  • @AntonArhipov

    @AntonArhipov

    5 ай бұрын

    No. Kotlin is Scala without the nice things ;) (quoting Andrey Breslav's "Standing on the shoulders of giants" talk)

  • @deepakbisht4957
    @deepakbisht49576 ай бұрын

    I still don't get it why people are still saying kotlin is just a sugarcoat and nothing else. You just need to see last slides and it sums up everything. "Kotlin isn't just fancy syntax, it's a different kind of programming"

  • @zerettino
    @zerettino Жыл бұрын

    #9 is also not good in my opinion. The strategy pattern is still useful, and what is presented is not a good use of the pattern. The strategy pattern is not about implementing interfaces. And implementing a FlyBehaviour with "I cannot fly" makes no sense : if you cannot fly, you don't implement the FlyBehaviour. That being said, delegation is super handy, but we have to find another argument to sell it ;-)

  • @sarabwt
    @sarabwt9 ай бұрын

    I almost cannot believe that operator overloading was followed by think about the reader :D the example given is a way to brainfuck everyone reading it, even yourself after 3 months away. Saying movie1 < movie2 has a huge question mark of what you are even comparing. Year of release, number of cast members, movie rating, etc?

  • @deepakbisht4957

    @deepakbisht4957

    6 ай бұрын

    It's not a question mark it's just you are restricting your mind to compare only primitive numbers like int or something but it's OOPs and we should think like that way and create our own objects and operate them according to the real world things...

  • @sarabwt

    @sarabwt

    6 ай бұрын

    @@deepakbisht4957 This was two months ago, reading the comment and seeing movie1 It's not about restricting your mind, it is about information hiding and context dependence, that is bespoke to your program, not to mention, that you can never change it in case you were wrong the first time. I can easily imagine two movie codebases, that use same operators for different purpose. And that is incredibly shitty reading experience.

  • @HAAAAAA614
    @HAAAAAA6143 ай бұрын

    This feels like it was created by a 1st year comp sci major that listened to their favourite influencer about java bad Nullability is the only thing Kotlin has over Java and maybe I've not written enough java to get frustrated (I have) but getting null pointer errors, in 2024, with powerful IDEs is most definitely a skill issue. Extension functions in large code bases make code unreadable. Good luck finding the definition when you're not viewing from an IDE The only major difference between factory pattern and the Kotlin code is ... literally nothing. The Kotlin code eventually does the same thing the factory pattern does. Is your definition of Obsolete ... reinventing the wheel? Again, the DSL shown isn't that much different from the Java code. The maps? They look almost the same. Why was that even added? Lol Iterator? Just use Streams? Think of the reader, and not the writer? If I'm reading a code from an intern, and I see four Giving it actual movie names to makes no sense either from a readbility POV. It's much more readable if you do something like .premieredBefore(). Being fancy doesn't mean readability For the strategy pattern, why didn't you put all the kotlin code in one screen like you did for Java? You're not trying to exploit some human bias right? Right? Almost like you're trying to trick your viewers into reinforcing the believe that java is more verbose (which is right but not in this scenario). Did you intentionally try to make the java code more verbose? The final keyword isn't needed. The public keyword isn't needed since the class is package private. Given the context, instantiating a new Behvaiour isn't needed either. new BehaviorTypeHere().fly() in the fly method would have been enough Istg the only people that love kotlin are those that like to feel "smart" or "fancy when coding. Kotlin is just good PR team. If you're gonna hate on Java, at least bring up Golang. Apple didn't choose kotlin as the main language for their new language lol This was fun to do. Good video. Now I go back to writing stupid c# so I can have somewhere to live

  • @ZelenoJabko
    @ZelenoJabko2 жыл бұрын

    All these things kotlin stole from scala. Wow such revolutionary

  • @guai9632

    @guai9632

    2 жыл бұрын

    Scala didn't invent those either

  • @ZelenoJabko

    @ZelenoJabko

    2 жыл бұрын

    @@guai9632 not all of them, but many

  • @guai9632

    @guai9632

    2 жыл бұрын

    none at all

  • @mattdoestechstuff

    @mattdoestechstuff

    2 жыл бұрын

    Quite a few things actually existed in C# many years ago. But what does it matter, if langauges didn't learn from other languages and take what's good here and there, we would have langauges so seperated that evolve way slower

  • @patrikeriksson8410

    @patrikeriksson8410

    2 жыл бұрын

    Sure most things have been stolen, but unfortunately you're incorrect: Scala still doesn't even have #1 from the talk non-nullable types and nullable types with compiler-check, you have to do it the tedious way like Java and wrap with Optionals.. Scala is great but such a pain to code in sometimes

  • @jimishukurow2286
    @jimishukurow22869 күн бұрын

    Map.of() hit me

Келесі