Deciding between a computed property and a function in Swift

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ค. 2024
  • In this video we explore Swift's computed properties and I talk about the different things I consider when deciding which type of property I should use.
    This video is a companion video for: www.donnywals.com/deciding-be...
    Level up your Swift Concurrency skills with my course: donnyplus.com/p/practical-swi...
  • แนวปฏิบัติและการใช้ชีวิต

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

  • @srzurka
    @srzurka 19 วันที่ผ่านมา

    Thanks for the video. I concur. I would only add that, computed properties feel Swifty to me so I start with a bias towards using them, then change to a function when there's one of the situations that you've identified. (needs arguments, it's not lightweight, potential side-effects, etc)

  • @tiagoalexbastos
    @tiagoalexbastos 19 วันที่ผ่านมา

    your videos are so good man, top tier content! Keep it up :)

  • @nigelgee3576
    @nigelgee3576 19 วันที่ผ่านมา

    I know that you are using person name as an example code. But it should said that when dealing with with names that should use PersonNameComponentsFormatter as this will put the correct format for user locale

  • @user-qg8nc5bk4p
    @user-qg8nc5bk4p 19 วันที่ผ่านมา

    Sound became better :)
    Could you please share your thoughts on usage of extensions, e.g. extending models with some methods, formatting methods etc.
    When an object that does something is better than extension of some model that handles the model certain way and returns the data I need, the only think that comes to my mind is inability to use DI in extension, so testability is limited for these functionality

    • @DonnyWalsdev
      @DonnyWalsdev  12 วันที่ผ่านมา +1

      I've added it to my (long) list of potential topics!

  • @alexandr8328
    @alexandr8328 19 วันที่ผ่านมา

    Hello! When is your Swift Concurrency course released? It says it is still in progress. Thx

    • @DonnyWalsdev
      @DonnyWalsdev  12 วันที่ผ่านมา

      Hey! The course should be finished in the next week or two. Plan was to have it fully done this week but I'm currently at a conference so that seems a little too ambitious. Almost all sections are finished except for the final one on TaskGroup and async let.