Avoid THIS Readability Mistake In Jetpack Compose

Поділитися
Вставка
  • Опубліковано 6 вер 2024
  • Follow for more Android & Kotlin tips 🙌

КОМЕНТАРІ • 24

  • @yurowitz
    @yurowitz Рік тому +5

    For those who didnt understand, this video is about not using trailing lambdas (when you have a composable, with the last parameter being an invokable runnable, then you can simply type it in a trailing lambda instead of explicitly typing it as a parameter)
    This will confuse others who read your code because they will think its some Composable function and not a NORMAL function
    This is merely for code readability purposes

  • @MaxWeninger
    @MaxWeninger Рік тому +14

    A general thing I always teach is - "Imagine someone without using an IDE or advanced editor looks at this code." So make it as clear as possible - like always writing named parameters - to see what is going on

    • @the_woof
      @the_woof 11 місяців тому

      Just because some guy slacks off and not reviews MR properly noone should suffer. As long as IDE with all code services exists, it is a crime to force people to write code like if they in 1980s

    • @vibovitold
      @vibovitold 2 місяці тому

      ​@@the_wooffor a start, you don't get IDE hints looking at the Git diffs (even on GitHub and the like)

  • @megakb91
    @megakb91 Рік тому +4

    One the best things introduce by kotlin in general, not just for Compose

  • @khanzadakashif8248
    @khanzadakashif8248 Рік тому +3

    I do this because I often forget what the parameter was,, so I always use named parameter so can tell by just looking at the function call.

    • @MaxWeninger
      @MaxWeninger Рік тому +1

      Exactly - and its no extra work at all - you write it once and profit every time you see it

  • @Marco-dr2on
    @Marco-dr2on Рік тому

    Tip: You can easily move the lambda argument into the parentheses by just pressing Alt+Enter and selecting this refactoring from the menu 😊

  • @lepro0
    @lepro0 Рік тому

    😂😂 and I proudly been doing this all over the place
    Thanks Phillip

  • @shubhamnanche
    @shubhamnanche Рік тому

    Bro.. just increase the volume when you edit your shorts 😅 It's relatively lower than other youtube videos. Love your vids btw ❤

  • @alexnovikov1609
    @alexnovikov1609 Рік тому +1

    So in short, Rule #1:
    With @Compose, we should avoid using non composable trailing lambda expressions outside of parentheses, since that's the usual place for composable content functions. Also it is better to use named parameters to make it clear.
    It looks reasonable.

  • @worlddatanexus
    @worlddatanexus Рік тому

    Thank you! 👍

  • @pqsk
    @pqsk Рік тому

    Great tip

  • @aapipcps2311
    @aapipcps2311 Рік тому

    Hey Philips, can you do comparation how fast you designing with Jetpack Compose vs XML pleasee 😊

  • @filipepinheiro8250
    @filipepinheiro8250 Рік тому

    I do that and usually advise ppl in my team to do that too, I thought it was a me thing, apparently more people agree, thanks u guys 😂

  • @shadownet3960
    @shadownet3960 Рік тому

    Why do we always use a :: for a viewmodel plz

  • @TheBlackManMythLegend
    @TheBlackManMythLegend Рік тому

    it's more like a kotlin mistake... I like to use named stuff all the time to avoid any mistake as a rule of thumb I don't really think too much about it.

  • @manshalkhatri9289
    @manshalkhatri9289 Рік тому

    😮

  • @federicocreti4699
    @federicocreti4699 Рік тому

    I think this is the first i didn't understand what the hell are you saying! 😅😅

  • @mnmr1996
    @mnmr1996 Рік тому

    So avoid trailing lambdas?

    • @camilohernandezruiz2776
      @camilohernandezruiz2776 Рік тому

      in composable functions only because normally the trailing lambda is used to declare another inner composable