How senior iOS devs test & refactor legacy code with Massive View Controllers | Live Dev Mentoring

Поділитися
Вставка
  • Опубліковано 7 січ 2025

КОМЕНТАРІ • 20

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

    Sign up to gain FREE access to exclusive iOS dev courses, workshops, and mentoring sessions: www.essentialdeveloper.com/community?

  • @munzrs
    @munzrs 9 місяців тому +1

    Mark my words. When I become a lead dev this will be required material for my team. Such high quality content that the iOS community sorely needs. Thank you, ED!

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

    HI, should we test the functions of extensions (like String extension, Collection extension, and Date extension) that we wrote?

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

      Hello. We recommend you write automated tests for all behavior in your apps.

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

      @@EssentialDeveloper thank you for your answer.
      But, I still concern about this.
      For example: I write Date extension with func toString() -> String. Then I use it function in my view model to convert Date -> String. I do not write unit test for that view model yet. So now I start to write test for that view model.
      The question is Should I write more test for just extension function? Not include in test case of view model.

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

      If you test it through the ViewModel behavior, you don't need to test the extension directly. In fact, the extension can be considered an implementation detail and even be private/internal.

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

      @@EssentialDeveloperunderstood. Thank you

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

      One more question.
      Should we use 3rd libs for testing (like Quick & Nimble)? My collagues and some experienced iOS developers in my city suggest to use Quick & Nimble instead of XCTest because that lib provide a quick way to write test quick, readble and effective than XCTest. I dont know that is true or not and why we should use and why not.

  • @TungNguyen-qr4rn
    @TungNguyen-qr4rn Рік тому

    Thank for your content. I have a question:
    If my public method is too complex to test like they have 100 lines long and call several private methods, and each private method call some functions from dependencies.
    What should I do? How can I test this public method? And if i have new changes in some private methods so How can i test them through public method?

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

      Hello. It seems like this method is doing too much. Consider breaking it down. And if you want to make changes to private methods because of requirement changes, you should first add a failing test through the public interface, then make a change to the private method to make the test pass. This way, the new behavior will be covered by tests through the public interface. Finally, if the change in private method doesn't change the behavior (aka refactoring), you don't need to change tests because the behavior is already covered.

    • @TungNguyen-qr4rn
      @TungNguyen-qr4rn Рік тому

      @@EssentialDeveloper Thank for reply. I have one more question. For example:
      If the private methods are complex, to test public method i need to mocking dependencies of private methods so much. Should i extract these private methods to another class with an abstraction? Or any better approach? Thank you!

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

      Consider breaking down complex components into simple components that can be composed to achieve the complex behavior.

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

    Is it possible to clean the table view cell from memory once the view controller is de initialize? The table view cell is empty still it showing me in graph memory.

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

      Hello! Yes, it's done automatically for you as long as you don't have any other objects referencing them.

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

      @@EssentialDeveloper there is no code inside the cell. still, it shows me in the graph. Also, the view controller is de initialize successfully.

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

      It could be code *outside* the cell holding it in memory.

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

      @@EssentialDeveloper ok let me try to check and try to clear. thanks for your reply.

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

    Thank you Caio & all ED instructors

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

    hi