Master C# Delegates Like a Senior Developer | How to write better delegates in C#

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

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

  • @TuralSuleymaniTech
    @TuralSuleymaniTech  11 месяцев назад +1

    The source code of the video: github.com/TuralSuleymani/DecodeBytes/tree/tutorial/masterCsharpDelegatesLikeSenior
    PS: In this particular example, I was focusing on demonstrating a specific concept, and I opted for the simpler 'foreach' syntax for brevity. The repo contains materialization for Cards.
    By materializing results first, you ensure:
    1. Only a single database query is executed, improving performance and predictability.
    2. You have a concrete collection of entities in memory for iteration.
    3. Each iteration of the foreach loop potentially triggers a separate database query to fetch the next entity if you use dbset with foreach.

  • @CodingMindsMadrid
    @CodingMindsMadrid 5 месяцев назад +1

    hey brother im a junior developer from Spain and i want to thank you for all youre doing for us, its the first time that i really can understand how delegates work in a real world context and not just learning how to write a func or predicate but really understanding when and why i should do it. Thanks a lot!

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  5 месяцев назад

      Hey man, Thanks a lot. I'm really happy that you if was helpful. I'll continue to create such type of understandable content. Thank you again for your comment. You made my day!

  • @shehan.akalanka
    @shehan.akalanka 2 месяца назад

    This is the most efficient way to learn something, in my opinion. When we're presented with the problems we need to solve, it helps us understand why we're using certain concepts. You're a great teacher!❤

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  Месяц назад

      Thank you so much for your kind words! 😊 I'm really glad to hear that you find this approach helpful. Solving real problems is definitely the best way to learn and understand concepts more deeply. Keep up the great work! 💪

  • @uvieemma3854
    @uvieemma3854 5 месяцев назад

    Smiles..this is 100% solid explanation. i like the way you explain some topics.....will definitely be watching this account hence forth. Thanks mate.

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  5 месяцев назад

      Awesome, thank you! Glad you liked it! Thanks for watching and subscribing!

  • @dragonboy8891
    @dragonboy8891 11 месяцев назад +1

    Wonderful! I'm self-learning and don't quite understand delegate before, but now I can put it to work thanks to your explaination. Keep the good work.

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  11 месяцев назад +2

      That's great!
      Really happy to hear that. Keep up the self-learning, it's a valuable skill.

  • @claudio1983
    @claudio1983 7 месяцев назад

    FINALLY I UNDERSTOOD DELEGATES XD Thanks very much, very good video!

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  7 месяцев назад

      Glad to hear that! You're welcome! Thank you for subscribing!

  • @TuralAsgar
    @TuralAsgar 10 месяцев назад

    Nobody explained these topics like you.
    Thank you!

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  10 месяцев назад

      You're very welcome! I'm glad my explanation was helpful and insightful. It's always rewarding to know I've contributed to someone's understanding of a complex topic

  • @eldarzeynalov2703
    @eldarzeynalov2703 11 месяцев назад +1

    Congratulations Tural. I'm proud of you ❤

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  11 месяцев назад

      Thank you @eldarzeynalov2703, really appreciate it! Hope you liked it

  • @vladmaiorov1072
    @vladmaiorov1072 4 месяца назад

    Very useful, thank you!

  • @Naton
    @Naton 10 месяцев назад +1

    i tried learning haskell once before C#.
    i found that delegates are like haskell typeclass.

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  10 месяцев назад

      Thanks for sharing! Haskell is also one of the interesting languages to learn

  • @TuralAsgarAZ
    @TuralAsgarAZ 10 месяцев назад

    Mən özüm də proqramlaşdırmanı struktulu olaraq videodakı şəxsin dərslərilə öyrənməyə başlamışam. 👍

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  10 месяцев назад +1

      Thank you @TuralAsgarAZ, your support is really valuable. Thank you for spending the time to write a comment!

  • @riskyOriginal
    @riskyOriginal 11 месяцев назад +1

    10/10 thank you!

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  11 месяцев назад

      That means a lot to me! Your support motivates me to keep creating.

  • @AloneBoy-1001
    @AloneBoy-1001 11 месяцев назад

    Thx bro, that was a cool course. Im appreciates for your time that spent to recording vidoes. keep going to teaching more titles 👍

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  11 месяцев назад

      That's awesome to hear,! I put a lot of effort into these videos, and it's great to know they're paying off. I'm always working on new content, so be sure to subscribe to stay updated on the latest releases.

  • @KieranFoot
    @KieranFoot 10 месяцев назад

    Senior Developer using a foreach on an DbSet/IQueryable is a bit odd. I understand it isn't the focus of the video, but especially in teaching content, I always try to use best practices in all contained code to avoid confusion down the line.

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  10 месяцев назад

      Thanks for pointing this out! I always appreciate feedback that helps me ensure my content aligns with best practices. You're absolutely right that using foreach on a DbSet or IQueryable can have potential implications, and I should have been more mindful of that in the video.
      In this particular case, I was focusing on demonstrating a specific concept, and I opted for the simpler foreach syntax for brevity. Added DbSet materialization to the branch

  • @khanfaizan05
    @khanfaizan05 11 месяцев назад +1

    Very nice. Amazing .. subscribed already..❤

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  11 месяцев назад

      "Thank you so much! I'm so glad you enjoyed the video. I really appreciate you subscribing!

  • @IGODX
    @IGODX 11 месяцев назад +4

    I don't like the example that you used here

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  11 месяцев назад

      Thank you for your comment! I'd be happy to hear the reason for taking your feedback into account and to use better examples in the future.

    • @MirkoMaranzano
      @MirkoMaranzano 11 месяцев назад +1

      I can understand why your example it's not liked by @IGODX. You are enumerating a DBSet, in a real world scenario it can cause major issues.
      Would have been better if your example had been based on a simple collection rather than a DBSet.

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  10 месяцев назад

      Good catch! Thank you for your comment! Actually the purpose was explaning and focusing to delegates rather than DbSet usage. Definitely I'll take it into account in my future videos.

  • @kvelez
    @kvelez 11 месяцев назад +1

    20:46
    using ConsoleApp1;
    var cards = GetCardsByDelegate(3, new CustomerDelegate(cutomerId => cutomerId < 4)); // Lambda
    cards.ForEach(card => Console.WriteLine(card));
    Console.ReadKey();
    static List GetCardsByDelegate(int customerId, CustomerDelegate customerDelegate) // Delegate
    {
    var cards = new List();
    using var dbcontext = new CustomerAppDbContext();
    var query = from card in dbcontext.Cards // LINQ
    where customerDelegate(card.CustomerId)
    select card;
    cards.AddRange(query.ToList());
    return cards;
    }
    // Delegates
    public delegate bool CustomerDelegate(int customerId);

    • @TuralSuleymaniTech
      @TuralSuleymaniTech  11 месяцев назад

      Hi @kvelez, thank you for your comment. Definitely, using 'customerId' from the argument is another implementation that fits especially for your LINQ method implementation.