|
| 1 | +## GitHub Copilot Hackathon Extended Drilling Exercises (Up to 60 Minutes - Adjust as Needed) |
| 2 | + |
| 3 | +This extended set of exercises will further explore GitHub Copilot's capabilities within VS Code. Aim to spend roughly 1-2 minutes on simpler exercises and 2-3 minutes on more complex ones. |
| 4 | + |
| 5 | +**Setup:** |
| 6 | + |
| 7 | +1. ✅ Open Visual Studio Code. |
| 8 | +2. ✅ Ensure you have the GitHub Copilot extension installed and are logged in. |
| 9 | +3. ✅ Open an existing code project (or create a more substantial one with multiple files, functions, and potentially some comments for better exploration). |
| 10 | + |
| 11 | +**Exercises:** |
| 12 | + |
| 13 | +1. ✅ **Exploring Basic In-line Suggestions:** (Same as before - Reinforce the basics) |
| 14 | + * Start typing common code structures. Observe and accept/ignore suggestions. |
| 15 | + |
| 16 | +2. ✅ **Getting Alternative In-line Suggestions:** |
| 17 | + * Type some code and wait for an in-line suggestion. |
| 18 | + * Press `Ctrl+Enter` (or `Cmd+Enter` on macOS) to open the Copilot window with alternative suggestions. |
| 19 | + * Browse through the alternatives and select one you like. |
| 20 | + * **Goal:** Learn how to access and choose from multiple in-line suggestions. |
| 21 | + |
| 22 | +3. ✅ **Understanding Codebase with `@workspace /explain` (Revisited):** (Same as before - Emphasize on a more complex part of the codebase) |
| 23 | + * Use `@workspace /explain` on a more intricate section of your code. |
| 24 | + |
| 25 | +4. ✅ **Generating Diagrams with `@workspace` (More Specific):** |
| 26 | + * Use `@workspace /diagram` with more specific instructions (e.g., "Show the data flow for the user registration process.", "Create a component diagram for the main modules."). |
| 27 | + |
| 28 | +5. ✅ **Generating Unit Tests with `#selection` (Multiple Scenarios):** |
| 29 | + * Select different types of code (e.g., a function with conditional logic, a class method) and use `#selection write unit tests`. |
| 30 | + * **Goal:** See how test generation adapts to different code structures. |
| 31 | + |
| 32 | +6. ✅ **Targeting Codebase Understanding with `@workspace #folder /explain` (Multiple Folders):** |
| 33 | + * Try using `@workspace #folder` with different folders in your project to understand their respective roles. |
| 34 | + |
| 35 | +7. ✅ **Referencing a Specific File with `@workspace #file /explain` (Different File Types):** |
| 36 | + * Use `@workspace #file` to ask questions about different types of files in your project (e.g., configuration files, data structures). |
| 37 | + |
| 38 | +8. ✅ **Referencing a Specific Function with `@workspace #sym /explain` (Complex Functions):** |
| 39 | + * Select a function with more complex logic or multiple nested calls and use `@workspace #sym /explain`. |
| 40 | + |
| 41 | +9. ✅ **Generating Documentation with Selection (Different Levels of Detail):** |
| 42 | + * Select code and try prompts like `Write a concise documentation summary for #selection` and `Write detailed JSDoc-style documentation for #selection`. |
| 43 | + * **Goal:** Explore different levels of documentation generation. |
| 44 | + |
| 45 | +10. ✅ **Generating Tests with Selection (Edge Cases):** |
| 46 | + * Select a function and try prompting `Generate unit tests for #selection including edge cases and error handling.`. |
| 47 | + * **Goal:** See if Copilot can anticipate and generate tests for less common scenarios. |
| 48 | + |
| 49 | +11. ✅ **Reviewing Code with Selection (Specific Focus):** |
| 50 | + * Select code and try prompts like `Review #selection for potential security vulnerabilities.` or `Review #selection for code style consistency.`. |
| 51 | + * **Goal:** Learn to guide the code review process with specific concerns. |
| 52 | + |
| 53 | +12. ✅ **Using `#terminalLastCommand` for Contextual Help:** |
| 54 | + * Execute a command that resulted in an error in the terminal. |
| 55 | + * In the chat, type: `#terminalLastCommand What caused this error and how can I fix it?`. |
| 56 | + * **Goal:** See how terminal output can be used for debugging assistance. |
| 57 | + |
| 58 | +13. ✅ **Discussing VS Code with `@vscode` (Settings and Features):** |
| 59 | + * Ask `@vscode` about specific settings (e.g., "How do I enable word wrap?") or features (e.g., "Explain how the debugger works in VS Code."). |
| 60 | + |
| 61 | +14. ✅ **Generating Code with In-line Chat (Specific Task):** |
| 62 | + * In a code file, type a comment describing a small code snippet you want to generate (e.g., `// Function to calculate the factorial of a number`). |
| 63 | + * Observe the in-line suggestions and accept a suitable one. |
| 64 | + * **Goal:** Practice using comments to guide in-line code generation. |
| 65 | + |
| 66 | +15. ✅ **Refactoring Code with In-line Chat:** |
| 67 | + * Select a piece of code that could be improved (e.g., a long function). |
| 68 | + * In the in-line chat (after selecting), type: `Refactor this code to be more readable.` or `Extract this logic into a separate function.`. |
| 69 | + * **Goal:** Explore Copilot's ability to suggest and perform basic refactoring. |
| 70 | + |
| 71 | +16. ✅ **Explaining Code with In-line Chat:** |
| 72 | + * Select a line or block of code you want to understand. |
| 73 | + * In the in-line chat (after selecting), type: `Explain this code.` or `What does this line do?`. |
| 74 | + * **Goal:** Quickly get explanations for unfamiliar code snippets. |
| 75 | + |
| 76 | +17. ✅ **Generating Code Snippets with Chat (More Complex):** |
| 77 | + * In the Copilot Chat, describe a more complex code snippet you need (e.g., "Write a Python function that reads data from a CSV file and returns a list of dictionaries."). |
| 78 | + * **Goal:** Practice using the chat for generating larger and more specific code blocks. |
| 79 | + |
| 80 | +18. ✅ **Asking Follow-up Questions in Chat:** |
| 81 | + * After Copilot provides a response in the chat, ask a follow-up question to refine the answer or explore related topics. |
| 82 | + * **Goal:** Understand the iterative nature of interacting with Copilot. |
| 83 | + |
| 84 | +19. ✅ **Using `@workspace` to Find Code:** |
| 85 | + * In the Copilot Chat, type: `@workspace Find all occurrences of the function named 'processData'.`. |
| 86 | + * **Goal:** Learn how to use `@workspace` for code search within your project. |
| 87 | + |
| 88 | +20. ✅ **Generating Code Based on Examples in Chat:** |
| 89 | + * Provide a small example of the code you want (e.g., "I want a function that takes a list of strings and returns a new list with the length of each string. For example, ['apple', 'banana'] should return [5, 6]."). |
| 90 | + * Then ask Copilot to generate the function. |
| 91 | + * **Goal:** See how providing examples can guide code generation. |
| 92 | + |
| 93 | +21. ✅ **Using `#selection` for Code Transformation:** |
| 94 | + * Select a block of code and ask Copilot to transform it (e.g., `Convert #selection from JavaScript to Python.`, `Make #selection use arrow functions.`). |
| 95 | + * **Goal:** Explore basic code transformation capabilities. |
| 96 | + |
| 97 | +22. ✅ **Generating Comments for Existing Code:** |
| 98 | + * Select a block of uncommented code and ask Copilot to `Add comments to #selection explaining the logic.`. |
| 99 | + * **Goal:** See how Copilot can help improve code readability through comments. |
| 100 | + |
| 101 | +23. ✅ **Asking About Best Practices with `@workspace`:** |
| 102 | + * In the chat, ask: `@workspace What are some best practices for error handling in this project?` or `@workspace Suggest ways to improve the performance of this module.`. |
| 103 | + * **Goal:** Leverage `@workspace` for getting advice on code quality and best practices within your codebase. |
| 104 | + |
| 105 | +24. ✅ **Using In-line Chat for Quick Modifications:** |
| 106 | + * Select a variable name and use the in-line chat to ask: `Rename this variable to 'itemCount'.`. |
| 107 | + * **Goal:** Practice using in-line chat for small, focused code modifications. |
| 108 | + |
| 109 | +25. ✅ **Exploring Different In-line Suggestion Styles:** |
| 110 | + * Type code in different styles (e.g., verbose vs. concise) and observe how Copilot's suggestions adapt. |
| 111 | + * **Goal:** Understand the influence of your coding style on Copilot's suggestions. |
| 112 | + |
| 113 | +26. ✅ **Using `@workspace` to Understand Project Structure:** |
| 114 | + * In the chat, ask: `@workspace Describe the overall architecture of this project.` or `@workspace What are the main modules and their dependencies?`. |
| 115 | + * **Goal:** Use `@workspace` to get a high-level understanding of your project's organization. |
| 116 | + |
| 117 | +27. ✅ **Generating Data Structures with Chat:** |
| 118 | + * In the chat, describe the data structure you need (e.g., "Generate a JSON object representing a customer with properties for name, email, and address."). |
| 119 | + * **Goal:** Practice generating data structures using natural language in the chat. |
| 120 | + |
| 121 | +28. ✅ **Asking for Explanations of Technical Concepts:** |
| 122 | + * Use the Copilot Chat to ask general programming questions (e.g., "What is the difference between synchronous and asynchronous programming?", "Explain the concept of recursion."). |
| 123 | + * **Goal:** Utilize Copilot as a learning resource for technical concepts. |
| 124 | + |
| 125 | +29. ✅ **Combining `#file` and `#sym` for Focused Questions:** |
| 126 | + * In the chat, type: `@workspace #file:<path/to/your/file.js> #sym:<name_of_a_function_in_that_file> What are the potential side effects of this function?`. |
| 127 | + * **Goal:** See how combining `#file` and `#sym` allows for very precise questions. |
| 128 | + |
| 129 | +30. ✅ **Experimenting with Creative Prompts:** |
| 130 | + * Try using more open-ended or creative prompts in the chat (e.g., "Write a short poem about this code.", "Suggest three alternative ways to implement this feature."). |
| 131 | + * **Goal:** Explore the more imaginative capabilities of Copilot. |
| 132 | + |
| 133 | +**Wrap-up:** |
| 134 | + |
| 135 | +* ✅ Discuss which new commands and techniques were most insightful. |
| 136 | +* ✅ Encourage participants to continue exploring the documentation and experimenting with different prompts. |
| 137 | +* ✅ Emphasize the importance of providing clear and specific prompts for the best results. |
| 138 | + |
| 139 | +This expanded set of exercises should provide a more comprehensive exploration of GitHub Copilot's features within VS Code, drawing directly from the provided documentation. Remember to adjust the time allocated for each exercise based on the participants' pace and the complexity of the tasks. |
0 commit comments