Using GitHub Copilot to Write Complex Code | Step-by-step Tutorial

Поділитися
Вставка
  • Опубліковано 25 чер 2024
  • Become a patron and get access to source code and exclusive live streams: / using-github-to-81382359
    In this video, you will learn how to apply GitHub Copilot - "your AI pair programmer" - to implement a feature with considerable complexity in an ASP.NET application backed by Entity Framework Core. Copilot will help write code through all the layers, consistently following the requirements. Most importantly, Copilot will "understand" the requirements within the domain model, where any discrepancy to requirements is a bug that might be hard to discover.
    You will witness the issues when using Copilot, and their mitigations. Most notably, the AI tool will not propose correct code when facing a large portion of the feature. As this video demonstrates, apparently a good approach to using GitHub Copilot effectively is to split any large method into smaller ones. That will help Copilot "understand" each small part of the feature in separation and, eventually, offer a good implementation.
    And when everything else fails, you will learn a powerful technique of guiding GitHub Copilot's decisions with code comments. With only a brief comment, we can specify the critical parts of requirements that Copilot must obey in the code it suggests next. Needless to say, that part of the demonstration turned to be the only one with no bugs introduced whatsoever.
    Last but not least, you will witness a gross discrepancy in number of bugs in parts of the implementation where Copilot was left rampant, producing large blocks of code at once, almost unattended, and those portions of code where it only generated a few lines of code, often in a very small method.
    Overall impression is that GitHub Copilot can be an effective tool to write code with significant improvement in typing speed, while it is not as reliable when a programmer expects it to figure out a request with corner cases, branching logic, proper use of the domain model, etc.
    Related videos:
    Coding with GitHub Copilot - Beginner to Master ► • A Comprehensive Guide ...
    How to Make No Bugs? Write Code Incrementally! ► • How to Make No Bugs? W...
    Content:
    00:00 Intro
    01:12 Copilot doing dependency injection
    06:33 Copilot implementing a domain class
    12:14 Debugging code generated by Copilot
    13:48 Why so many bugs?
    Learn more from video courses:
    Beginning Object-oriented Programming with C# ► codinghelmet.com/go/beginning...
    Collections and Generics in C# ► codinghelmet.com/go/collectio...
    Making Your C# Code More Object-oriented ► codinghelmet.com/go/making-yo...
    Other courses at Pluralsight ► codinghelmet.com/go/pluralsight
    Other courses at Udemy ► codinghelmet.com/go/udemy
    Other videos on this channel you may be interested in watching:
    Using GitHub Copilot to Write Complex Code | Step-by-step Tutorial ► • Using GitHub Copilot t...
    Coding with GitHub Copilot - Beginner to Master | VS Code Demo ► • A Comprehensive Guide ...
    What is Covariance and Contravariance in C# ► • What is Covariance and...
    How to Initialize a Clean ASP.NET Core Project with Entity Framework Core and Identity ► • How to Initialize a Cl...
    The Null Conundrum: A Guide to Optional Objects in C# ► • How to Avoid Null Refe...
    #githubcopilot #dotnet #vscode
  • Наука та технологія

КОМЕНТАРІ • 12

  • @zoran-horvat
    @zoran-horvat  Рік тому +2

    Become a patron and get access to source code and exclusive live streams: www.patreon.com/posts/using-github-to-81382359
    Share your thoughts and experience using AI tools to write code! Write a comment if you have any questions or concerns regarding AI-generated code, or if you just wish to share what happened when you tried it out.

  • @silkogelman
    @silkogelman Рік тому +2

    Even though I program in Python your video was insightful about how to apply Copilot in a better way.
    Thank you for this video Zoran.

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

    Thank you, great video!

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

    My suggestion is to use commenting to help drive Copilot so that it better understands what you are thinking. Just looking at your code it will try make assumptions which wont often give the results you expect. I use comments through out and using descriptive wording is a skill in itself which makes coding a more creative process imho.

  • @AaronShaverEng
    @AaronShaverEng 9 місяців тому

    I wonder how well it would do with a TDD approach; probably less debugging needed

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

    When you accept the code suggestion, you have to then manually add using statements for the new code. Shouldn't Copilot be able to do that when it pastes in the code?

    • @zoran-horvat
      @zoran-horvat  Рік тому

      Is that a line from the actual demo in this video? I cannot recall right now that any part of the demo requires the using.
      But that is a good observation. I might try that out and see whether Copilot knows that disposable objects must be disposed.
      Or is your question about the using directive for dependencies? I think that Copilot does not add them because it only adds code locally - under the caret. From how I see it, Copilot does not make changes in any other part of the file but the current line, and hence cannot add a directive at the top of the file.

  •  11 місяців тому

    I am writing 10 controller and exactly same each other. When I write a new controller, copilot cannot understanding. Basically I have list and pageable API endpoints. And copilot don't understanding

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

    why so many bugs? no unit tests! how does copilot cope with unit tests, and is it able to produce implementation code better if well assembled unit test prepared?

    • @zoran-horvat
      @zoran-horvat  Рік тому +1

      That will be the future video!
      But anyway - good observation.

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

      @@zoran-horvat happy to seeing it

  • @georget5874
    @georget5874 8 місяців тому

    this stuff is so lame, if you want it to fill a type with dummy data or something it doesnt have a clue.. the stuff it can do, you dont really need much help with