Misleading practices of SwiftUI on the internet

Поделиться
HTML-код
  • Опубликовано: 20 окт 2024

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

  • @nirajtiwari8141
    @nirajtiwari8141 2 года назад +3

    Very important point of summoning ViewModel in a test case was covered in this video.
    How am I supposed to test ViewModel, if it its a part/extension of View ? Developers should
    start reasoning about what they learn from internet. Also, every piece of software we write,
    needs to be tested. So, those who do not think of testing, will never think about such tight
    coupling between Views and ViewModels. That can work for someone's hobby projects.
    But while writing enterprise apps, such approach is simple going to be discarded.

  • @ITisSimpul
    @ITisSimpul 2 года назад +2

    People nowadays look for a Great Place to Work Certified organization, instead they should look for an organization to work with Great People. That reminds me of you Ravi.. Great work as always, I am not able to follow all your videos, but whenever I see your Videos, I feel great and happy!
    I recommend you to cover "Power of Process" in your upcoming videos (if possible)
    All my best wishes with you!

    • @CodeCat15
      @CodeCat15  Год назад

      Indeed, it’s always good people who drive the process with their right mindset than taking things casually.
      Thank you for considering me as one of those person, and it means a lot coming from you Sir. I’ll try my best to do better.
      It’s always a pleasure reading comments from you, and I’ll cover the Power of Process in my coming videos soon.

  • @PanchalIleshkumar
    @PanchalIleshkumar Год назад +1

    Hi Ravi,
    I very well understand your explanation. Thanks for your videos!
    FYI we can access a private variable in the test case to set them `private (set)` you can check at 9:30. Just for idea but you are write model should be independent bot encapsulated within view.

    • @CodeCat15
      @CodeCat15  Год назад

      yes that I missed while recording the session, thank you for letting me know about it.

  • @yogeshdate99
    @yogeshdate99 Год назад +1

    Nice ravi
    always happy your comment creative developers...😄😄

    • @CodeCat15
      @CodeCat15  Год назад

      Glad the video was helpful Yogesh 😊

  • @garimapandey1006
    @garimapandey1006 9 месяцев назад

    Thanks for clearing up the bad coding practices that are found on the internet. 😊

    • @CodeCat15
      @CodeCat15  9 месяцев назад

      Glad it was helpful 😊

  • @CodeCat15
    @CodeCat15  Год назад

    Note: For creating the viewModel class inside the view extension, In the test cases, you could directly access the viewModel without creating the instance of the ContentView but still we would have the same problem, the VM are not independently testable and reusable. I would leave that choice to the developer to how they want to write tests for their application but mostly if a component is being tested you should be able to directly access that component without having to go through some other component.

    • @anupdsouza
      @anupdsouza Год назад

      Do you have the link to the Apple Dev's response @4:53 ? The link that appears there is somewhat misleading since it doesn't contain that actual response and seems to have been picked from somewhere else.

  • @aniketkumar3218
    @aniketkumar3218 Год назад

    Does using @FetchRequest in views is a bad practice too. In the repository pattern video you mentioned that the view shouldn't have the idea of using CoreData. I tried using your idea of creating two data models one for coredata and one which gets fetched from internet sent to views etc. Exposed this proxy model and used @Published property to observe for changes. But the problem with this is loss of efficiency. Coredata objects are fetched in a fault state and thus requires very less memory. On the other hand create struct objects will mean every property gets loaded in the ram. Very confused about creating an offline app in swiftui that can fetch objects from internet and serialise them into persistence layer. Any help will be appreciated.

    • @CodeCat15
      @CodeCat15  Год назад +1

      What’s the difference between the property wrappers @FetchRequest vs FetchRequest coz both will do the same thing for you so how do you loose efficiency?

    • @aniketkumar3218
      @aniketkumar3218 Год назад

      @@CodeCat15 The published array is of Network Fetched Model which is struct and not a NSManagedObject. When you use @FetchRequest or FetchRequest it gives you CoreData entities. These are efficient because of the data fault state as i mentioned earlier. When i convert these entities to the structs i mentioned earlier to expose as a @Published array every piece of data will be loaded into RAM.

    • @aniketkumar3218
      @aniketkumar3218 Год назад

      if i use @FetchRequest in views i need to work with coredata entity models directly which causes various issues if passed in a different thread than the context with which object was created. We will need to use perform/performAndWait to get these objects which ties the whole code with Coredata logic strongly

  • @arbinnawaz1953
    @arbinnawaz1953 9 месяцев назад +1

    Beautifully explained :)

    • @CodeCat15
      @CodeCat15  9 месяцев назад +1

      Thanks a lot 😊

  • @rachitsharma8829
    @rachitsharma8829 2 года назад +1

    Very well explained 👌👍

    • @CodeCat15
      @CodeCat15  2 года назад

      Glad it was helpful, do share the video with your iOS group and feel free to ask questions.

  • @AppDeveloperPoint
    @AppDeveloperPoint 2 года назад +1

    Nice video Ravi. 👍

    • @CodeCat15
      @CodeCat15  2 года назад

      Glad it was helpful, do share the video with your iOS group and feel free to ask questions.

  • @tajhassan1925
    @tajhassan1925 2 года назад +1

    Loved it sir😊😊

  • @umarparacha653
    @umarparacha653 2 года назад +1

    Good to see

    • @CodeCat15
      @CodeCat15  2 года назад

      Good to know about the misleading practices before than later

  • @Prashant-7
    @Prashant-7 Год назад +1

    Why not. let obj = ContentView.ProductViewModel() ??

    • @CodeCat15
      @CodeCat15  Год назад +1

      I forgot to mention that in the video so I added a note as comment for this specific code,
      yes you could do that but the point is you’ll still have tight coupling between view and the VM and if you want to pass that VM in some child view you can’t

    • @Prashant-7
      @Prashant-7 Год назад

      @@CodeCat15 Agree on this

  • @yogeshdate99
    @yogeshdate99 2 года назад

    Nice Ravi

    • @CodeCat15
      @CodeCat15  9 месяцев назад

      Thank you Yogesh 😊