DevTalk
October 14, 2024
10
min read

Liuba Gonta and Yuliya Khadasevic - GitHub Copilot Beyond the Basics - 10 Ways to Elevate Your Coding

Daniel Cranney

Welcome to a captivating journey through GitHub Copilot's advanced features, as discussed in a session by Liuba Gonta, a software developer and GitHub certified trainer at Xipier Netherlands, along with her colleague, Software Development Consultant, Yuliya Khadasevic. Designed for developers eager to leverage AI to enhance their coding practices, this summary unwraps the conversation held around the tool’s magic and intricacies, to explain how it actually works and how to make it for you.

Agenda

During their 30-minute session, Liuba and Yuliya had much ground to cover. Highlights included:

  1. An introduction to GitHub Copilot.
  2. Practical use cases demonstrating its value.
  3. An engaging live demo showing Copilot in action.

Limited by time yet enriched with insights, they achieved a delightful balance of speed and detail.

What is GitHub Copilot?

GitHub Copilot is an AI-powered code completion tool that assists developers by providing real-time code suggestions in multiple languages. This feature enables a seamless focus shift from monotonous coding tasks to more value-driven development work, maintaining productivity without stepping out of the IDE.

The core benefits of GitHub Copilot

Key Features

  1. Integration with Your IDE: No more context switching—Copilot stays within your favorite coding environment.
  2. Training from Public Repositories: Leverage the collective knowledge of millions of developers.
  3. Flexible Plans: Choose from individual, business, or enterprise plans, catering to various needs like team collaboration and administrative management.

How Does GitHub Copilot Work?

Understanding the magic behind the curtain can be enlightening. GitHub Copilot seamlessly operates through:

  • Context Collection: Gathering context from your coding environment.
  • Proxy Server Filtering: Ensuring that sensitive information and inappropriate content are scrubbed.
  • Large Language Model (LLM): Powered by OpenAI, this model processes the clean data to generate suggestions, later filtered for vulnerabilities.
How does GitHub Copilot work?

The Role of GPT

GitHub Copilot utilises two versions of GPT:

  • GPT-3.5: Offers faster code completions.
  • GPT-4: Handles chat interactions with more detailed results.

Practical Use Cases

To fulfill their promise, Liuba and Yuliya shared ten ways to elevate coding with Copilot:

  1. Auto-suggestions: Context-aware and adaptive to your style.
  2. Code Refactoring: Proposes best practice improvements.
  3. Unit Testing: Efficiently generates test cases.
  4. Acceptance Testing: Simplifies complex end-to-end tests.
  5. Debugging and Troubleshooting: Assists in identifying and resolving issues.
  6. Performance Optimization: Offers improved algorithms and methods.
  7. UI Development Assistance: Helps backend developers create UI components.
  8. Prompt Engineering: Improves result quality with refined inputs.
  9. Documentation: Updates and generates new documentation.
  10. Automated Testing: Produces comprehensive test suites for new features.

Live Demo

They demonstrated a simple web API project, showcasing the creation of a new method in Dutch and generating corresponding unit tests using xUnit and FluentAssertions.

Creating a New Method

// Original: Zoek op naam[HttpGet("searchByName/{name}")]public IActionResult SearchByName(string name) {var result = _context.Planes.FirstOrDefault(p => p.Name == name);if (result == null) return NotFound();return Ok(result);}

Writing Unit Tests

Next came the automated generation of test scenarios, an exercise in efficiency and creativity.

Acceptance testing using GitHub Copilot in action

Debugging and Fixing Errors

An error around an internal server issue showed Copilot’s prowess by suggesting the use of FirstOrDefault() instead of First().

// Original: var flight = _context.Flights.First(f => f.Id == id);// Suggested fix:var flight = _context.Flights.FirstOrDefault(f => f.Id == id);

Optimizing Performance

A suspiciously slow prime number calculation was swiftly optimized, cutting execution time from 3 seconds to mere milliseconds.

Final Thoughts

While GitHub Copilot can enhance the developer experience, some key takeaways include:

  • Set Clear Goals: Better prompts lead to better suggestions.
  • Focus on Instructions: Give detailed examples for expected outcomes.
  • Be Creative: Experiment with various input techniques.
  • Don’t Over-Rely: Always review suggestions, maintaining control over the code.

Liuba and Yuliya's session was both interesting and clear, helping developers to leverage the power of GitHub Copilot in their everyday workflows with actionable insights, tips and tricks.

Liuba Gonta and Yuliya Khadasevic - GitHub Copilot Beyond the Basics - 10 Ways to Elevate Your Coding

October 14, 2024
10
min read

Subscribe to DevDigest

Get a weekly, curated and easy to digest email with everything that matters in the developer world.

Learn more

From developers. For developers.