Flutter TDD Clean Architecture Course [6] - Repository Implementation

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ก.ย. 2024

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

  • @verryondrums
    @verryondrums 4 ปีที่แล้ว +12

    Thank you so much! It's so good to finally see the TDD approach in full practice and not only 10 minute talks...

  • @juliano_mio
    @juliano_mio 4 ปีที่แล้ว +10

    I think this is by far the best TDD tutorial there is! Thanks a lot and keep it up Matej :)

  • @abderrahmansettani9843
    @abderrahmansettani9843 5 ปีที่แล้ว +19

    finally ! your Efforts are very much appreciated bro

    • @MrKiazmitakar
      @MrKiazmitakar 3 ปีที่แล้ว

      ​@Callan Landyn How does this relate to the tutorial?

  • @eduardoblas2315
    @eduardoblas2315 4 ปีที่แล้ว +31

    Where do you learn all this TDD style?Do you have any cool resources to practice this TDD style with mocks? Any book similar to your style?, BTW cool videos. Hard to find this kind of content.

  • @virtomize
    @virtomize 3 ปีที่แล้ว +9

    the test 'should check if the device is online',
    wasn't working for me since
    repository.getConcreteNumberTrivia(tNumber);
    wasn't mocked with a proper when call
    adding
    when(mockRemoteDataSource.getConcreteNumberTrivia(tNumber)).thenAnswer((_) async => tNumberTrivaModel);
    in the arrange section fixed this

    • @gameofcodes9832
      @gameofcodes9832 ปีที่แล้ว

      Yes I got the same issue, but why it worked in video ?
      Got any idea?

    • @cromuelbarut9859
      @cromuelbarut9859 ปีที่แล้ว

      thanks for this

    • @henriquevmelo
      @henriquevmelo ปีที่แล้ว

      @@gameofcodes9832 Because there was no Null Safety checks in Dart at the time the tutorial was recorded. It means now getConcreteNumberTrivia cannot return Null. Instead you have to provide a mocked value.

  • @MrRoxx17
    @MrRoxx17 3 ปีที่แล้ว +1

    Boi that stuff is lit.
    It's hard to find good intermediate to advanced coding tutorials, this one is fire bro!

  • @virtomize
    @virtomize 3 ปีที่แล้ว +5

    I run into an issue with the test
    'should return server failure when the call to remote data source is unsuccessful'
    verifyZeroInteratctions(mockLocalDataSource);
    returned an error and i had to add
    reset(mockLocalDataSource) in the arrange part to fix all previous interactions with this mock since it seems not to reset within a test() block.
    If this is the case every test should start with a cleanup to reset all mocks before doing testing to not rely on the order of the tests.

  • @darielsubiros3787
    @darielsubiros3787 3 ปีที่แล้ว

    Hello Matej. 1 year after you publish this amazing series I'm starting to learn Flutter, but I want to do it the right way, by having a very well organized code as I can see clean architecture and TDD can do.
    I had made a question, but it was my bad, I was coding along with you while watching the video, but I realized I had a mistake.It's already solved so I edited this comment to delete such question.
    Thanks a lot, and keep it up with your awesome videos buddy!
    God bless you!

  • @ahmederabti1990
    @ahmederabti1990 5 ปีที่แล้ว +4

    It seems very overwhelming. The whole 'clean' architecture thing. Could you provide a more in-depth series on clean architecture alone without TDD? Or if you could provide me with any easy-to-comprehend resources to follow? Awesome work btw as always thanks.

    • @ResoCoder
      @ResoCoder  5 ปีที่แล้ว +6

      It's true that doing TDD can be a bit confusing when you're also learning about the overall architecture. I'm yet to find an easy to follow clean architecture resource (except for this course 😉).
      Just try looking at the diagram from the first part and also notice the dependencies of different classes. This is what really matters with Clean Architecture.

    • @thcdenton
      @thcdenton 2 ปีที่แล้ว +1

      "Clean Architecture: A Craftsman's Guide to Software Structure and Design" (Robert C. Martin)

  • @gaxkiller
    @gaxkiller 4 ปีที่แล้ว +12

    Hi, thank
    By the way, I am wondering how at 14:42 , expect(result, equals(Right(tNumberTrivia))); can pass the equality test since they are not the same type. At least for me, it says:
    Expected: Right:
    Actual: Right:
    And the test fail even if NumberTriviaModel extends NumberTrivia

    • @kshitijrajale3751
      @kshitijrajale3751 4 ปีที่แล้ว

      Have you added line 38 at 7:33.
      Also, check if you are using Equatable package.

    • @ABDULLAHUSMANI91
      @ABDULLAHUSMANI91 2 ปีที่แล้ว

      Make sure the method 'getConcreteNumberTrivia' in repository implementation is 'async'

  • @iMaxos
    @iMaxos 4 ปีที่แล้ว

    Absolutely brilliant, I've been dreaming of an architecture like this since I started object oriented programming. Thank you for this content, I am very grateful.

  • @gpj-qo9cb
    @gpj-qo9cb 5 ปีที่แล้ว +13

    Could you possibly do a short video on clean architecture with Firebase?

  • @michalisioak7512
    @michalisioak7512 3 ปีที่แล้ว +3

    nice video. But I have some questions. 1) what counts as a feature?(when should I make a new feature) and 2) should I put in the core folder a domain & data ? Thanks

  • @juantaverasiv741
    @juantaverasiv741 5 ปีที่แล้ว +1

    Excellent video!!! Your usage of TDD and Clean Architecture are outstanding

  • @chetan6406
    @chetan6406 5 ปีที่แล้ว +4

    Always great tutorials....I follow your series....please make tutorial on firebase integration with flutter

    • @jesselima_dev
      @jesselima_dev 4 ปีที่แล้ว

      After I finish this series I will start a Flutter App with Firebase. I guess your doubts are pretty close to mine. To listen Firebase data changes passing from the datasource until UI layer. I think that is when Bloc or Provider comes to play. Not sure how yet.

    • @ResoCoder
      @ResoCoder  4 ปีที่แล้ว +2

      I'm preparing a Firebase series!

    • @jesselima_dev
      @jesselima_dev 4 ปีที่แล้ว

      @@ResoCoder WoW!! Really? That would be great. I just started an Flutter App. I stopped due to design architecture issues. That's why I am doing this Flutter TDD course first. The only one I found that really focus on Clean and Tests. I already seem to much spaghetti UI Apps. And I really do not want mine to be like those.

  • @jesselima_dev
    @jesselima_dev 4 ปีที่แล้ว +1

    Awesome! Really great refactor at the end.

  • @maran.ath4
    @maran.ath4 ปีที่แล้ว +2

    Edit: this was a lot easier to finish without null safety than this comment depicts, I was still new to flutter then...
    with null safety, this is just absolutely impossibleeee😂😂 I'm tired, I've been patching up the other parts, but this particular video is impossible, it's been hours, change one thing and the ripple effect will tear you down, I am beginning to feel clean architecture is more trouble than it's worth, I mean not the clean architecture itself, but the testing testing and writing code based on tests, it's silly, it forces you to necessarily make things nullable, like all my Future? literally everything has to be nullable for tests to work😥😥😪😪 and it's useless, because these will never be null, now, when I'm implementing them, I have to start checking for null with ! ! ! !.......ughhhhhhhhhhh, and now I can't check for network connectivity because, can't do a conditional with a null value

    • @zehijean8817
      @zehijean8817 ปีที่แล้ว

      hum iam doing the tutorial now also with null safety and i didnt struggle as much as you are depicting in your comment...for the Future just keep everything as is it shouldnt fail your tests...check also similar repositories online which implement this proposal with null safety

    • @maran.ath4
      @maran.ath4 ปีที่แล้ว

      @@zehijean8817 lol, what are you saying??
      You know when you're running the early tests, you actually have not implemented anything yet, so, the results are gonna be implicitly null in the tests, hence null errors, type null can't be assigned to....
      Check in the comments, you'll see people complaining of said error, the only way out is to make the return types nullable

    • @maran.ath4
      @maran.ath4 ปีที่แล้ว +2

      @@zehijean8817 yep, I just done what you asked, now even after fully implementing the repo, and for the get trivia from the number from the repo test, failing miserably
      type Null is not a subtype of type Future

    • @maran.ath4
      @maran.ath4 ปีที่แล้ว

      @@zehijean8817 ouuh, thanksssssss

    • @cerencanbaz
      @cerencanbaz ปีที่แล้ว

      moral bozma lan

  • @ecovillaraza2953
    @ecovillaraza2953 2 ปีที่แล้ว

    Thank you so much, you are an amazing human being .

  • @fleepgeek
    @fleepgeek 5 ปีที่แล้ว

    Finally!!! Been waiting impatiently for this part.
    Now i know what it feels like when my subscribers wait for my previous series.
    You're really doing a good job man.
    I want to see how this ends because im currently loving it and if it goes well, i would be using this architecture for future contents.
    Thanks once again for your quality content.

  • @diego2020e
    @diego2020e 2 ปีที่แล้ว +2

    I am trying to enter to read the articles but it seems that the page does not work

  • @mohabmagdy4155
    @mohabmagdy4155 4 ปีที่แล้ว

    Thank you very much =) I really appreciate your work this course worth billions. I promise once I used TDD for my client's project I will support you on Patreon or PayPal keep up the great work .btw I make youtube videos too I will use your TDD to build a full big app in combination with my knowledge really thanks for your work.

  • @Juanpa097
    @Juanpa097 5 ปีที่แล้ว

    These videos are GREAT!!!!! THANKSSSSSS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @ShadowInfest
    @ShadowInfest 5 ปีที่แล้ว +3

    Duration is getting longer, content is getting better

    • @ResoCoder
      @ResoCoder  5 ปีที่แล้ว +4

      I'm glad you learned something new!

  •  5 ปีที่แล้ว +2

    Great tutorial. Hugs from the biggest brazilian community #Flutterando o/

  • @ino9138
    @ino9138 4 ปีที่แล้ว

    5:35 just want to say that if you use "verify" insted of "expect", you'll get pass whether you input True Or False in the arrange. or CMIIW

  • @carrillocarlosce
    @carrillocarlosce 5 ปีที่แล้ว

    Awesome, looking fordward to watch next videos

  • @uDropper
    @uDropper 8 หลายเดือนก่อน

    why didn't you put the first test inside the 'device is online' subgroup?

  • @LostNotFound24
    @LostNotFound24 3 ปีที่แล้ว +1

    amazing series! any course with more focus on writing tests, widget tests, unit tests, reusing common test logic etc.?

  • @SarjanaTravel
    @SarjanaTravel ปีที่แล้ว

    i have problems, the arguement type 'future' can`t be assigned to the parameter type 'dynamic Function()'

  • @kristijanbarabas9476
    @kristijanbarabas9476 ปีที่แล้ว +2

    abstract class NetworkInfo {
    Future? get isConnected;
    }
    adding an ? operator solved my Future error

    • @jeffreymercado1659
      @jeffreymercado1659 7 หลายเดือนก่อน

      Thanks! It was evaluatin doing that, and seeing your comment motivated me to try, and it worked also for me!

  • @HashemRC
    @HashemRC 4 ปีที่แล้ว

    awesome tutorial, I feel Im on track

  • @tomasjablonskis6053
    @tomasjablonskis6053 2 ปีที่แล้ว +1

    My recommendation would be to NEVER EVER check anything that is associated to device connectivity before doing a request, it can potentially be flaky, just let your HTTP client throw connection error.

  • @psybitcoin
    @psybitcoin 4 ปีที่แล้ว +2

    After 14:42 I get Failure instead of dynamic... Anyone have ideas on whats happening?

    • @ABDULLAHUSMANI91
      @ABDULLAHUSMANI91 2 ปีที่แล้ว

      Make sure the method 'getConcreteNumberTrivia' in repository implementation is 'async'

  • @josecoverlessons
    @josecoverlessons 4 ปีที่แล้ว

    you are the best keep it up

  • @volodymyrbobyr5256
    @volodymyrbobyr5256 4 ปีที่แล้ว

    since the `should cache the data...` test shares everything but one line with `should return remote data` test, would it not be as clean to combine the two and just assert both the data is cached and returned all in one test?

  • @Starrk321
    @Starrk321 4 ปีที่แล้ว

    Hi, if I don't want to use high order functions, I can use for example an optional variable or in TDD isn't a good practice?

  • @CandiceWilliams_
    @CandiceWilliams_ ปีที่แล้ว

    I wish I had more time to pick this up so I know how to communicate with my devs and explain how I need to be able to access payment history and user referrals with my flutter app so I can create reports to keep my affiliates and stockholders up to date… if any one has any tips please share. I appreciate you so much in advance.

  • @kulveersinghdhanoa
    @kulveersinghdhanoa 3 ปีที่แล้ว

    Getting this error... Error-The superclass, 'Bloc', has no unnamed constructor that takes no arguments.

  • @sushilghorasaini7883
    @sushilghorasaini7883 3 ปีที่แล้ว

    Sir, same like NumberTrivia entity, what to do if we have to deal with stream data. How to implement it inside domain repository. Is implemenying Either , or, dartz with stream data??

  • @adeelzahid9622
    @adeelzahid9622 3 ปีที่แล้ว

    very hard to understand it, it takes my whole day .. let's see what's next 👍 overall best series on TDD CA ✔✌

  • @eincandela
    @eincandela 3 ปีที่แล้ว

    Thanks again for such a great value. I'm struggling to understand how Right() method knows" which types it must refers to. This all Either/Right/Left is still a little obscure for me. Could you lead me to a tutorial about that part ?

  • @roshanchamlagain
    @roshanchamlagain 4 ปีที่แล้ว

    what is name of the plugin that you used for generating arrange, act, assert scaffold?

  • @pedrodelacruz2369
    @pedrodelacruz2369 2 ปีที่แล้ว

    excellent!!

  • @jeffpena3986
    @jeffpena3986 3 ปีที่แล้ว

    How to tell repository to use other datasource from the presentation layer? In this example you are relying on the internet connectivity to use other datasoruce.

  • @diego.coder26
    @diego.coder26 4 ปีที่แล้ว

    In summary, in the repository implement is the business logic developed? And in the use cases is it called only? greetings from Chile

  • @SpellOdyssey
    @SpellOdyssey 3 ปีที่แล้ว

    Failed assertion: boolean expression must not be null
    package:clean_architecture_tdd_course/features/number_trivia/data/repositories/number_trivia_repository_impl.dart 28:25 NumberTriviaRepositoryImpl.getConcreteNumberTrivia

  • @dawidniegrebecki2205
    @dawidniegrebecki2205 4 ปีที่แล้ว

    Great video!!

  • @user-tf4cd2rw3t
    @user-tf4cd2rw3t ปีที่แล้ว

    Hey man, are you fine? You uploaded your last video one year ago. Hope everything is okay.
    If you read this: Thanks for your videos! They are awesome!

  • @user-sg5kr2ou2u
    @user-sg5kr2ou2u 5 ปีที่แล้ว

    Thank you!!

  • @eduardorabanal2803
    @eduardorabanal2803 5 ปีที่แล้ว

    Amazing video again bro, thanks a lot. Could you upload the final code to check it please? I would greatly appreciate that.

  • @jeevanpillay
    @jeevanpillay 5 ปีที่แล้ว

    Thanks bro

  • @josecoverlessons
    @josecoverlessons 4 ปีที่แล้ว

    man I copied from the website, and I get errors such as ERROR: Failed assertion: boolean expression must not be null, ERROR: Bad state: Can't call test() once tests have begun running.
    could you post the entire document from this particular lesson? so that I can check maybe I made a mistake somewhere along the lines?

    • @jesselima_dev
      @jesselima_dev 4 ปีที่แล้ว

      Don't copy, code along. You'll learn much more and the code works as well the tests.

  • @mahdibasiratnia7518
    @mahdibasiratnia7518 4 ปีที่แล้ว

    Wow! such a great tutorial!
    but is TDD really worth it for small to medium flutter projects? I know using TDD in this tutorial is for educational purposes (and its a great fit for clean architecture indeed), but generally asking.

    • @mahdibasiratnia7518
      @mahdibasiratnia7518 4 ปีที่แล้ว

      also, what are your thoughts about 'flutter_clean_architecture' on pub? its architecture is a little bit different than what you explained here. thanks, bro.

  • @MrKsuhiyp
    @MrKsuhiyp 4 ปีที่แล้ว

    Cool

  • @DuongBui-dq6km
    @DuongBui-dq6km 4 ปีที่แล้ว

    what is aaaTest extendsion?

  • @rahmatsugiarto859
    @rahmatsugiarto859 2 ปีที่แล้ว

    cool

  • @luisbaltodano1941
    @luisbaltodano1941 4 ปีที่แล้ว

    What's the diference between ServerException and ServerFailure?

    • @marialijideveloper2006
      @marialijideveloper2006 4 ปีที่แล้ว +1

      According with the documentation ServerException when the response doesn't have a 200 OK , then failures are ServerExceptions became failures because the Repository will catch the Exceptions and return them using the Either type as Failures. For this reason, Failure types usually exactly map to Exception types.

  • @AnhTuan-vf2gv
    @AnhTuan-vf2gv 5 ปีที่แล้ว +1

    your structure is awesome, bro.
    But i have a question to ask: "How if i have many features? And how to navigate the Screen between them across features?

    • @Belliger1991
      @Belliger1991 4 ปีที่แล้ว

      I asked my self the same thing. I lean towards mixing it with the Atomic Design Pattern (a frontend Pattern see: bradfrost DOT com/blog/post/atomic-web-design/) where i would map the "features as organisms or even as templates" therefore i have a top level directory called pages where i pull my features together in routable "views".
      Sadly Uncle Bob Martin in his talks as the Creator of the Clean architecture design seldom goes into that level of detail in all the application layers (thats why it's more popular in the backend) . But it works very well wit an MVC pattern mixed in which is somewhat visible in the most outer layer of the Diagramm in the first episode :)
      But i'd like to hear from @ResoCoder on what he had in mind :)

    • @AnhTuan-vf2gv
      @AnhTuan-vf2gv 4 ปีที่แล้ว

      @@Belliger1991 yes, i think we should keep watching him. Hope he'll give us a most resonable answer.
      But in my personal opinion, anyway finally we have to place all of modules in somewhere called "App Module". And the App Module should be the place we'll inject every dependencies.
      In the Core Folder, we may create a class called Page Router or something like that, and this Page Router will take all of navigate missions, then every screens in each Module can ask Page Router for navigating.
      This is my opinion, how about you?

    • @JonesDTaylor
      @JonesDTaylor 4 ปีที่แล้ว +1

      @@Belliger1991 the layered architecture presented in these videos is for a whole application (back end/front end/ api etc) while the atomic design is just a design pattern for the presentation layer (UI), same goes for MVC. Once you adopt a clean architecture you can use whatever design pattern you want in each of your layers (MVC, flux, atomic etc). I hope this helps.

    • @mohabmagdy4155
      @mohabmagdy4155 4 ปีที่แล้ว

      @ResoCoder please tell us your thoughts on this point

  • @alexN350z
    @alexN350z 4 ปีที่แล้ว

    Only thing I don't like is to use higher order function

  • @Teclys23
    @Teclys23 4 ปีที่แล้ว

    I'm fucking in love with you, man!

  • @pathakvivek7865
    @pathakvivek7865 5 ปีที่แล้ว

    quite long wait this time..

  • @roubert7823
    @roubert7823 3 ปีที่แล้ว

    31:26 where stop

  • @qubits016
    @qubits016 2 ปีที่แล้ว

    I would like to thank your biological parents for bringing you into this world.

  • @christianmereles7764
    @christianmereles7764 3 ปีที่แล้ว

    Anyone getting error on:
    final result = tNumberTriviaModel.toJson();
    final expectedMap = {
    "text": 'Test text',
    "number": 1,
    };
    expect(result, expectedMap);
    ----Terminal: ----
    Expected: {'text': 'Test text', 'number': 1}
    Actual: {'text': 'Test text', 'mumber': 1}
    Which: is missing map key 'number'

    • @weenitmaharjan1594
      @weenitmaharjan1594 3 ปีที่แล้ว

      Actual: {'text': 'Test text', 'mumber': 1} I thing there is typo in the loaded data.

  • @singhkamalpreet11
    @singhkamalpreet11 ปีที่แล้ว

    I am struggling with the test case. While setting up for exception I get this error on the test case
    No interaction expected, but following found: MockLocalDataSource.cacheNumberTrivia(null)

  • @markjoseultra6903
    @markjoseultra6903 4 ปีที่แล้ว +1

    This guy should be on the flutter boring show

    • @ResoCoder
      @ResoCoder  4 ปีที่แล้ว +8

      Am I that boring? 😂

  • @maran.ath4
    @maran.ath4 ปีที่แล้ว

    if you have Future error then, at the top of your testfile, delete the MockNetworkInfo,
    add this import
    import 'package:mockito/annotations.dart';
    then do this
    @GenerateNiceMocks([MockSpec()])
    import 'number_trivia_repo_impl_test.mocks.dart';
    after these, you will have reds, don't worry
    then in terminal, run flutter pub add -d build_runner, and after that flutter pub get
    then, in your terminal again, run this command
    flutter pub run build_runner build
    this will clear the errors you have after the command completes execution, and then your tests should work now

    • @hamidpinilla4431
      @hamidpinilla4431 ปีที่แล้ว

      Can you share your file to see the changes applied. I follow step by step your recommendations but the error in the annotation line still goes on

    • @maran.ath4
      @maran.ath4 ปีที่แล้ว

      @@hamidpinilla4431 I don't have access to my computer right now, make a GitHub gist with your code and send me the link let me see

    • @hamidpinilla4431
      @hamidpinilla4431 ปีที่แล้ว

      ​@@maran.ath4 I fixed it. The error was because the version of mockito that i used it doesn't included the decorator @GenerateNiceMocks yet

    • @maran.ath4
      @maran.ath4 ปีที่แล้ว

      @@hamidpinilla4431 so everything is working fine now?

    • @hamidpinilla4431
      @hamidpinilla4431 ปีที่แล้ว

      @@maran.ath4 yes, thanks

  • @khalidrinaldy3671
    @khalidrinaldy3671 2 ปีที่แล้ว

    type 'Null' is not a subtype of type 'Future'
    MockNetworkInfo.isConnected
    What should i do ?

    • @pjpac7555
      @pjpac7555 ปีที่แล้ว

      the content of the tutorial seems to have been set before null safety implementation so that among other things // class "MockNetworkInfo extends Mock implements NetworkInfo {}" becomes "@GenerateNiceMocks([MockSpec()])" which addresses error messages such as "type 'Null' is not a subtype of".
      That said I'm still stuck with "expect(result, equals(Left(ServerFailure())));" in test\app\data
      epositories_impl
      umber_trivia_repository_impl_test.dart with rippling effects in lib/core/error/failures.dart.