Slide 1

Slide 1 text

Jinbo Wang, Senior Software Engineer, Microsoft Martin Lippert, Spring Engineering, Broadcom October 2024 GitHub Copilot + Spring: Making AI-assisted Coding Spring aware Copyright © 2024 Broadcom, Inc. or its affiliates.

Slide 2

Slide 2 text

How can AI assist Java development experience in IDE?

Slide 3

Slide 3 text

The Power of GitHub Copilot Code Completion Explain Fix Generate Docs Generate Tests Chat & Inline Chat

Slide 4

Slide 4 text

Suggest Refactoring: Use AI to plan refactoring

Slide 5

Slide 5 text

Refactor Code in a Specific Pattern - Replace ‘+’, ‘StringBuffer’ to ‘StringBuilder’, ‘Text Block’ - Escape String - Dedup repeated code - Migrate to design patterns (Builder, Singleton, etc.) - Extract long method to smaller ones …

Slide 6

Slide 6 text

Code Migration: Modernize Legacy Code - Text Block for Multiline Strings - Replace Loop with Streams API - Use Enhanced Switch Expressions - Use Pattern Matching for instance of

Slide 7

Slide 7 text

IDE Refactoring vs AI Refactoring ► IDE Refactoring - Rule-based, Predefined - Limited by IDE features - Requires developers to understand when and how to use it ► AI Refactoring - Trained on huge amounts of examples, easy to scale - More creative, can handle more complex refactoring pattern - Suggest refactoring the developer might not have considered

Slide 8

Slide 8 text

Influence the AI assistant (towards making it Spring aware)

Slide 9

Slide 9 text

In general, there are two ways Influence the AI assistant Changing the model itself (e.g. via fine tuning) Feeding additional information when asking (e.g. better prompts/questions, RAG, etc.)

Slide 10

Slide 10 text

The Copilot case in Visual Studio Code

Slide 11

Slide 11 text

Coding with an LLM Type your question

Slide 12

Slide 12 text

Coding with an LLM Type your question Generate a prompt for the LLM

Slide 13

Slide 13 text

Coding with an LLM Type your question Generate a prompt for the LLM Add context information

Slide 14

Slide 14 text

Coding with an LLM Type your question Generate a prompt for the LLM Add context information Send final prompt LLM

Slide 15

Slide 15 text

Coding with an LLM Type your question Generate a prompt for the LLM Add context information Send final prompt LLM Receive Response

Slide 16

Slide 16 text

Coding with an LLM Type your question Generate a prompt for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response

Slide 17

Slide 17 text

Coding with an LLM Type your question Generate a prompt for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project

Slide 18

Slide 18 text

Coding with an LLM Type your question Generate a prompt for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project

Slide 19

Slide 19 text

How to enhance Copilot?

Slide 20

Slide 20 text

APIs for Copilot There are APIs in place within VSCode to interact with Copilot: - API to submit prompts to the LLM yourself (direct use of Copilot LLM) - API to enhance Copilot Chat (open ended questions) - Enhance / change the prompt - Specify tasks - Fill in variables / placeholders - Enhance / modify the result (e.g. insert buttons) - Inline Chats: no extension API available yet - Side note: APIs are still evolving rapidly, moving target

Slide 21

Slide 21 text

Coding with an LLM Type your question Generate a prompt for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project Predefine the question, no need for the user to type something

Slide 22

Slide 22 text

Coding with an LLM Type your question Generate a prompt for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project Add more context to the prompt, but what exactly?

Slide 23

Slide 23 text

Coding with an LLM Type your question Generate a prompt for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project Show - and maybe enhance the response with additional information / actions

Slide 24

Slide 24 text

Coding with an LLM Type your question Generate a prompt for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project Be smart about where to and how to add code to the project

Slide 25

Slide 25 text

Making it Spring aware

Slide 26

Slide 26 text

Concrete Actions 1

Slide 27

Slide 27 text

Concrete Actions - We identify concrete actions where AI can help and provide a meaningful contribution - We craft the prompt with the necessary input, there is no user interaction - Not open-ended, very limited to a specific case Example: - 👍 Explain SpEL expression - 👍 Explain SQL/HQL/JPQL Query - 👍 Explain Pointcut expression - 🤔 CRON: eh, AI is too much for that, simple logic is enough

Slide 28

Slide 28 text

Latest Spring Tools release

Slide 29

Slide 29 text

Full Chat Agent 3

Slide 30

Slide 30 text

Chat Agent - Enhance the prompt (with random information) - Fully open-ended / chat experience - Enhancing the result (buttons + better code merge) - The more structure you ask for, the better you can interpret / merge the result

Slide 31

Slide 31 text

The Spring agent in action

Slide 32

Slide 32 text

The Spring agent in action

Slide 33

Slide 33 text

The Spring agent in action

Slide 34

Slide 34 text

The Spring agent in action

Slide 35

Slide 35 text

Challenges

Slide 36

Slide 36 text

LLM is changing behind the scenes 1

Slide 37

Slide 37 text

New Language or Framework Versions 2

Slide 38

Slide 38 text

Size limitations 3

Slide 39

Slide 39 text

Is it getting better or worse? 4

Slide 40

Slide 40 text

Questions

Slide 41

Slide 41 text

Thank you @https://github.com/testforstephen @martinlippert https://www.linkedin.com/in/martin-lippert-9a1909/ © 2024 Broadcom