Tips & Tricks: Get the Most Out of GitHub CoPilot | DevReach 2023

Progress Telerik
22 Nov 202359:42

TLDRTodd England, a member of the Cloud Advocacy team at Microsoft, delivers a comprehensive session on maximizing the utility of GitHub CoPilot, an AI-powered coding assistant. The talk commences with a light-hearted interaction, followed by an introduction to England's role and contact information. He then delves into the capabilities of GitHub CoPilot, illustrating how it functions using large language models to predict code completions based on existing code patterns. England emphasizes the importance of providing context for CoPilot to enhance its suggestions, showcasing various features like inline chat for coding inquiries and the ability to explain code snippets. Throughout the presentation, he demonstrates CoPilot's proficiency in generating, documenting, and testing code, alongside its limitations and the necessity for human verification of its outputs. England also explores CoPilot's integration with development environments like VS Code and Visual Studio, highlighting its potential to improve developer efficiency. The session concludes with a live coding example in Visual Studio 2022, where CoPilot assists in debugging by explaining an unhandled exception. The summary underscores the collaborative nature of coding with CoPilot, positioning it as a tool that amplifies developers' capabilities without replacing the need for human expertise.

Takeaways

  • 🌟 **GitHub CoPilot as a Pair Programmer**: It acts as an AI pair programmer, assisting in code writing, discovery, and understanding.
  • 📚 **Learning from Others**: Engage with peers who use GitHub CoPilot to learn new and useful ways it can be integrated into your workflow.
  • 💡 **Understanding Limitations**: Recognize the training data's impact on suggestions and that GitHub CoPilot is not a compiler, cannot perform actions, and requires context for accurate suggestions.
  • 🔍 **Context is Key**: Providing good context, such as open files, top-level comments, and meaningful names, significantly improves the suggestions from GitHub CoPilot.
  • ⚙️ **IDE Integration**: GitHub CoPilot integrates with various IDEs, including VS Code and Visual Studio, enhancing the development experience with its AI capabilities.
  • 🛠️ **Iterative Process**: Use an iterative approach when working with CoPilot, refining your prompts and accepting, rejecting, or modifying its suggestions to fit your needs.
  • 🧠 **AI Cannot Read Minds**: To get the best out of GitHub CoPilot, you must provide clear and specific guidance on what you want to achieve.
  • 📝 **Documentation and Testing**: GitHub CoPilot can assist in generating documentation and tests for your code, making your codebase more robust and maintainable.
  • 🔄 **Refactoring Aid**: Utilize CoPilot to refactor code, adhering to existing coding standards and practices within your project.
  • 🤖 **Debugging Assistance**: In Visual Studio, CoPilot can help understand and resolve exceptions during the debugging process, making it a valuable tool for troubleshooting.
  • 🚀 **Continuous Improvement**: Stay updated with the latest features and capabilities of GitHub CoPilot, as it continues to evolve and offer more functionalities to enhance developer productivity.

Q & A

  • What is the main topic of the talk at DevReach 2023?

    -The main topic of the talk is 'Tips & Tricks: Get the Most Out of GitHub CoPilot', focusing on how to maximize the use of the AI pair programmer tool, GitHub CoPilot.

  • Who is the speaker of the session?

    -The speaker of the session is Todd England, who is part of the Cloud Advocacy team at Microsoft.

  • What is the significance of the selfie moment mentioned in the transcript?

    -The selfie moment is significant as it marks the revival of DevReach in Bulgaria and aims to include the audience as part of a new tradition, making them feel like they are part of the event's history.

  • How does GitHub CoPilot function in the context of coding?

    -GitHub CoPilot functions by using large language models to understand large sets of data and predict what comes next based on a prompt or sequence. It provides code completions or comments based on pre-existing code patterns.

  • What are some limitations of GitHub CoPilot?

    -Some limitations of GitHub CoPilot include its reliance on training data, which means it may not perform as well with newer or less popular programming languages. It is also not a compiler, so it cannot check if the code is correct or runs. Additionally, it cannot read the user's mind, requiring clear context to provide accurate suggestions.

  • How can users provide better context to GitHub CoPilot?

    -Users can provide better context to GitHub CoPilot by keeping relevant files open, adding top-level comments to guide the tool, using meaningful names for variables and functions, and including specific comments to indicate the desired outcome in certain sections of the code.

  • What are some ways GitHub CoPilot can assist developers?

    -GitHub CoPilot can assist developers by writing basic code faster, helping to remember coding patterns or APIs, extending and refactoring existing code, explaining unfamiliar code, understanding and fixing errors, and even adding tests to the project.

  • How does GitHub CoPilot handle the process of adding tests to a project?

    -GitHub CoPilot can automatically generate test cases when prompted with a command like 'slash tests'. It creates a new test file and provides a framework for writing tests, which the developer can then accept and use as a starting point for their testing strategy.

  • What is the role of the developer when using GitHub CoPilot?

    -The developer acts as the 'pilot', guiding and verifying the suggestions made by GitHub CoPilot. They are responsible for understanding whether the code is correct, using their IDE to check for errors, and making decisions about how to implement the AI's suggestions effectively.

  • How can developers stay updated on the latest features and capabilities of GitHub CoPilot?

    -Developers can stay updated by visiting github.com/features or following the vscode YouTube channel for short, informative videos. They can also sign up for the waitlist to gain access to new capabilities as they are released.

  • What is the GitHub CoPilot Adventure and how can developers participate?

    -GitHub CoPilot Adventure is a new initiative that provides puzzles and challenges for developers to solve using GitHub CoPilot. It aims to help developers try new coding scenarios and problems. Developers can participate by visiting aka.ms/CoPilotAdventure to access beginner, intermediate, and advanced puzzles.

Outlines

00:00

😀 Morning Greetings and Introduction to GitHub Co-Pilot

The speaker, Todd England, starts the session with a warm welcome, light-hearted remarks about resting and partying, and an introduction to the topic of GitHub Co-Pilot. He emphasizes the tool's ability to act as an AI pair programmer, assisting in code development. The audience is encouraged to participate in a group selfie to become part of a new tradition. Todd introduces himself as part of Microsoft's Cloud Advocacy team and invites the audience to connect with him on social media.

05:00

🔍 Understanding GitHub Co-Pilot's Functionality and Limitations

The paragraph explains how GitHub Co-Pilot works, using large language models to predict code completions based on existing code patterns. It also discusses the limitations of the tool, such as the impact of training data, the inability to compile code, and the necessity for users to provide context for effective suggestions. The speaker highlights the importance of understanding these limitations to avoid potential pitfalls when integrating AI tools into the coding workflow.

10:02

📓 Providing Context to GitHub Co-Pilot for Better Suggestions

The speaker outlines various ways to provide context to GitHub Co-Pilot to improve its suggestions, including keeping relevant files open, using top-level comments, including in-file references, employing meaningful names, writing specific comments, and using sample code. These methods help GitHub Co-Pilot understand the user's intent and provide more accurate and targeted code completions.

15:03

🚀 GitHub Co-Pilot's Versatility in Code Development

The paragraph discusses the diverse applications of GitHub Co-Pilot, from writing basic code faster to aiding in remembering coding details, extending and refactoring existing code, explaining unfamiliar code, understanding and fixing errors, and even adding tests to a project. The speaker emphasizes the tool's potential to enhance various aspects of the development process beyond just writing code.

20:05

💻 Live Demo: Interacting with GitHub Co-Pilot in Real Time

The speaker conducts a live demonstration using GitHub Code Spaces, showcasing GitHub Co-Pilot's capabilities in real-time. The demo includes creating a function to sanitize HTML from a string, using specific and short comments, and trusting but verifying the suggestions provided by the tool. The speaker also demonstrates how to iterate on suggestions and use the explain feature to understand the code provided by GitHub Co-Pilot.

25:06

🔧 Iterating and Refining Code with GitHub Co-Pilot

The paragraph focuses on the process of refining code through iteration using GitHub Co-Pilot. The speaker demonstrates how to use direct prompts, function names, and the explain option to achieve the desired code outcomes. The importance of being descriptive in naming variables and functions is highlighted as a way to guide the AI towards providing useful completions.

30:07

📝 Documenting Code and Adding Tests with GitHub Co-Pilot

The speaker shows how GitHub Co-Pilot can assist in documenting code and adding tests. Using slash commands within the tool, the speaker demonstrates the automatic generation of documentation for methods and the creation of test files. The paragraph also covers how to ask GitHub Co-Pilot for guidance on installing testing frameworks and resolving errors encountered during testing.

35:09

🌐 Creating a Style Sheet with GitHub Co-Pilot

The speaker guides the audience through creating a CSS stylesheet with GitHub Co-Pilot. By providing goals and specific comments, the tool helps generate styles for a webpage's header and footer. The speaker also addresses the limitations of generating large amounts of content like Lorem Ipsum and instead uses an efficient method to achieve the desired result.

40:10

🔄 Iterative Code Refactoring with GitHub Co-Pilot

The paragraph demonstrates iterative code refactoring using GitHub Co-Pilot. The speaker uses the tool to correct function names to camel case and discusses the importance of context when suggesting changes. The speaker also shows how to use the inline chat feature to get suggestions for code improvements and how to accept or discard these suggestions.

45:12

📱 Contextual Suggestions with Open Files in GitHub Co-Pilot

The speaker emphasizes the importance of having the right files open when using GitHub Co-Pilot to ensure contextually accurate suggestions. By opening the to-do service file, the tool provides suggestions that closely match the existing coding style and project structure. The paragraph also covers the tool's ability to refactor code to meet specific coding standards.

50:14

💥 Debugging and Exception Handling with GitHub Co-Pilot

The speaker concludes with a demonstration of using GitHub Co-Pilot for debugging and understanding exceptions in Visual Studio 2022. By intentionally causing a stack overflow error, the speaker shows how the tool can explain the error and guide the user towards a solution. The paragraph highlights the tool's potential to enhance the debugging process and improve developer productivity.

55:15

📈 Recap and Future of GitHub Co-Pilot

The speaker recaps the key points discussed during the session, including the importance of using single, specific, and short prompts, trusting but verifying the suggestions, and the critical role of context. The paragraph also looks forward to future capabilities of GitHub Co-Pilot, such as handling pull requests, and encourages the audience to explore upcoming features and participate in Co-Pilot Adventures for a fun coding experience.

Mindmap

Keywords

💡GitHub CoPilot

GitHub CoPilot is an AI-powered programming assistant developed by GitHub and OpenAI. It is designed to help developers write code more efficiently by providing suggestions for code completions, helping with debugging, and even generating tests. In the video, it is portrayed as a 'pair programmer' that accelerates the coding process by understanding the context of the code and offering relevant suggestions, thus enhancing developer productivity.

💡Large Language Models (LLMs)

Large Language Models refer to AI models that are trained on vast amounts of data to understand and generate human-like text based on given prompts. In the context of the video, GitHub CoPilot utilizes LLMs to predict and suggest the next lines of code or comments, making it easier for developers to write and understand code. The video illustrates how these models work by referencing their ability to process and generate text, such as creating images or explaining code.

💡Code Completion

Code completion is a feature in many integrated development environments (IDEs) that suggests possible completions for the code a developer is writing. GitHub CoPilot excels at this by using its AI to predict what code should come next based on the current context. The video emphasizes the importance of providing specific and clear prompts to get the most accurate code completions from the tool.

💡Context

Context is critical when using GitHub CoPilot, as it helps the AI understand the developer's intent and the specific scenario the code is intended for. The video discusses various ways to provide context, such as open files, top-level comments, and specific variable names, which enable GitHub CoPilot to give more accurate and relevant suggestions.

💡Refactoring

Refactoring is the process of restructuring existing computer code without changing its external behavior. In the video, the speaker demonstrates how GitHub CoPilot can assist with refactoring code, making it more maintainable and readable. For example, the tool can help convert function names to camel case, adhering to common coding standards.

💡Debugging

Debugging is the process of identifying and removing bugs or errors from a computer program. GitHub CoPilot aids in this process by explaining exceptions and suggesting solutions directly within the IDE, as shown when the speaker intentionally crashes an application to demonstrate how CoPilot can help understand and resolve the resulting error.

💡Testing

Testing in software development involves the execution of programs or applications to verify that they work as expected. The video showcases GitHub CoPilot's ability to generate test cases for code, which can help ensure the quality and reliability of the software being developed. This feature is particularly useful for enhancing test coverage and maintaining code integrity.

💡Documentation

Documentation is the process of creating written descriptions of code, programs, and their features. In the video, GitHub CoPilot is shown to be capable of automatically generating documentation for methods and functions, which can save developers time and improve the maintainability of the codebase.

💡Pull Requests

Pull requests are a collaboration feature in version control systems, such as Git, where changes to the codebase are proposed and reviewed before being merged into the main branch. The video hints at future capabilities of GitHub CoPilot to assist with pull requests, potentially making the process of code review and integration more efficient and less error-prone.

💡Token Limit

The token limit refers to the maximum number of tokens that a large language model can process at one time. Tokens are the individual units of text that the model uses to understand and generate text. In the video, the concept is mentioned in the context of GitHub CoPilot's limitations when generating large amounts of text, such as a hundred lines of Lorem Ipsum, which would consume a significant portion of the token limit.

💡Code Spaces

GitHub Codespaces is a cloud-based development environment that allows developers to write, build, and test code directly from GitHub. The video mentions Codespaces in the context of using GitHub CoPilot within a browser-based IDE, highlighting the flexibility it offers for developers to work on their projects from anywhere.

Highlights

Introduction to GitHub CoPilot as an AI pair programmer designed to enhance developer productivity.

Todd England, from Microsoft's Cloud Advocacy team, presents tips and tricks for maximizing GitHub CoPilot's capabilities.

GitHub CoPilot utilizes large language models to predict code completions based on existing code patterns.

Understanding the limitations of GitHub CoPilot is crucial for effective use, such as its inability to compile code or read the developer's mind.

Providing context is key for GitHub CoPilot to offer accurate suggestions, including open files, top-level comments, and meaningful names.

GitHub CoPilot integrates with various IDEs, including Visual Studio Code and Visual Studio, enhancing the development experience.

The importance of specific, concise comments for guiding GitHub CoPilot to provide better code suggestions.

Iterative process of refining suggestions from GitHub CoPilot through continuous interaction and feedback.

GitHub CoPilot's ability to help write basic code faster and assist in remembering coding details.

Use of GitHub CoPilot for extending and refactoring existing code, explaining unfamiliar code, and understanding error messages.

Automatic generation of tests and documentation by GitHub CoPilot to improve codebases.

Live demonstration of GitHub CoPilot's real-time assistance during coding, including error explanation and test creation.

GitHub CoPilot's role in enhancing the debugging process by explaining exceptions and guiding developers to solutions.

Upcoming features of GitHub CoPilot, including functionalities for pull requests and more, available for preview.

CoPilot Adventures, a new initiative for developers to solve puzzles and explore new coding challenges with GitHub CoPilot.

Emphasizing that GitHub CoPilot is a tool to assist developers, not replace them, leading to more effective and happier programming.

Final thoughts on the transformative potential of GitHub CoPilot in software development and its impact on the future of coding.