The Difference between Sealed Interfaces & Sealed Classes!

Поделиться
HTML-код
  • Опубликовано: 20 окт 2024
  • 💻 Grab my Refactoring Legacy Code course here: bit.ly/47dzTLT
    In this video, we will discuss how sealed classes and interfaces can improve your code and examine the differences between them. By learning about these things, you will be able to use them better in your own code.
    🔗 Links:
    jorgecastillo....
    =========================
    📩 Sign up for my new newsletter 👇
    bit.ly/YCNewsl...
    =========================
    Join my Community on Discord 👇
    / discord
    👨🏽‍🏭 Who I am:
    I'm Younes Charfaoui, a Software Engineer and an Android Developer. I make videos about Android development, Technology, and productivity for software engineers.
    😋 Be My Friend:
    💻 GitHub - github.com/You...
    🐦 Twitter - / charfaouiyounes
    📑 Medium - / mxcsyounes
    📷 Instagram - / charfaoui.younes
    🌍 My website - www.charfaouiy...

Комментарии • 5

  • @hinocenciopaulo
    @hinocenciopaulo 2 месяца назад +1

    Finally someone that could make me understand why we need sealed interfaces. Thank you!

  • @rob92400
    @rob92400 2 месяца назад

    Hello!
    Do you think that, in the simple casese where we don't need a complex hierarchy, sealed classes and sealed interfaces are interchageable?
    I'm working on a project where developers tend to migrate from sealed classes to sealed interface for the sole purpose of sparing a couple of parenthesis. In my mind, the interface approach is more appropriate when there's behaviours (rather than properties) than need to be shared, so it leads to unproductive discussions :)
    It seems that Kotlin basically provides 2 ways to achieve very similar results, but they both stem from different concepts at the Java level.
    What do you think about this?

  • @iyadzac
    @iyadzac 2 месяца назад +1

    what about performance and memory? i think sealed interfaces don't need to instantiated, right?

    • @CharfaouiYounes
      @CharfaouiYounes  2 месяца назад

      Yeah but this is too negligible, and you won't notice any difference in performance at all!