Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AI Coding assistants - SingaDEV 10/01/2025

Michael Isvy
January 21, 2025
9

AI Coding assistants - SingaDEV 10/01/2025

There is currently a lot of momentum around AI coding assistants such as Cursor. Should you start using them? And if yes, which one should you use?
In this talk, Rajesh and Michael will build applications from the ground up using AI Coding assistants. Michael will focus on a Spring application and will assess the quality of the generated code. Rajesh will generate a full application with minimum guidance, in order to see if it is possible.

In the demos, we will mostly focus on Cursor but will likely touch other assistants such as Copilot and Windsurf.

Rajesh Lingappa is a seasoned technologist with over 25 years of experience in Telecom, eCommerce, and BFSI industries. Most recently, he served as Chief Architect for Consumer Banking at DBS. Prior to that, he co-founded and successfully sold a company called RedMart.

Michael Isvy works as VP of Engineering at cynapse.ai . He has been working with Java and Spring for the past 20+ years and has been diving into AI for the past 3 years.

Michael Isvy

January 21, 2025
Tweet

Transcript

  1. Who we are • Rajesh Lingappa ◦ Former Digital Ecosystems

    Platform Head at DBS Bank ◦ Over 2 decades of product delivery; over a decade of AI • Michael Isvy ◦ VP of Engineering at cynapse.ai (Computer Vision) ◦ 17 years of Java/Spring, 3 years of AI 2
  2. Agenda • Introduction to AI Assistants • Cursor deep-dive •

    Supervised coding ◦ Michael: generating Java/Spring code • Unsupervised coding ◦ Rajesh: building a full stack application with minimum supervision 3
  3. AI Assisted Coding - a new paradigm “It is our

    job to create computing technology such that nobody has to program. And that the programming language is human,” … “Everybody in the world is now a programmer. This is the miracle of artificial intelligence.” Jensen Huang at World Government Summit in Dubai. Feb 2024 “SaaS is Dead” Satya Nadella. Dec 2024 5
  4. 1. Code Completion, Explanation and Generation 2. Automated Testing 3.

    Code Review Automation 4. Refactoring large codebases 5. Documentation . . . AI for Software Engineering 6
  5. 1. Increased Developer Productivity 2. Better Test Coverage 3. Personalized

    Developer Assistance 4. Improved Decision Making 5. Code Exploration and Familiarization Benefits of AI for Software Engineering 7
  6. 1. Evolving Standards, Models and Tools in flux 2. Overestimating

    AI’s capabilities 3. Complexity in Integrating AI tools 4. Potential performance overhead 5. Potential security Risks in generated code Gotchas of AI for Software Engineering 8
  7. Prelude: state of AI coding assistants in IntelliJ • IntelliJ

    is Java developers’ solution of choice ◦ Great reputation among Java developers Source: Baeldung's 2024 Survey 10
  8. IntelliJ support • AI support is limited • Our bet:

    Jetbrains is preparing a major update IntelliJ + Copilot VSCode + Copilot Cursor (based on VSCode) In-editor Chat ✅ ✅ ✅ Code gen with diff ❌ ✅ ✅ Code gen as you type ❌ 😐 ✅ Community and Doc 😐 😐 ✅ Misc. (terminal, git messages…) ❌ ✅ ✅ 11 Disclaimer: These might change by the time this talk is over :) demo: GreetingService IntelliJ
  9. Cursor: the new kid in the block? • Has taken

    the dev community by storm in only 3 months ◦ Now used by over 100,000 developers ◦ Windsurf and Copilot are catching up fast • Super-focused on developer experience • Still a young company ◦ Only 20 people at the time of writing! • https://www.cursor.com/ 12
  10. Cursor implementation • Fork of VSCode with embedded AI capabilities

    ◦ Still compatible with all VSCode plugins • No support yet for other IDEs ◦ IntelliJ, Pycharm, GoLand, Visual Studio, etc https://forum.cursor.com/t/please-consider-a-jetbrains-plugin/17042/31 13
  11. Service class Springifying an application JUnit test 15 @Service public

    class StudentService { private final StudentRepo studentRepo; public StudentService(StudentRepo studentRepo){ this.studentRepo = studentRepo; } } @SpringBootTest public class StudentServiceTest { @Autowired private final StudentService studentService; @Test public void shouldFindStudentById() { } } demo: GreetingService part 1
  12. Constructor Injection Quiz: which type of Injection in a Spring

    bean? Field Injection Setter Injection 16 @Service public class StudentService { private final StudentRepo studentRepo; /* No @Autowired */ public StudentService(StudentRepo studentRepo){ this.studentRepo = studentRepo; } } @Service public class StudentService { @Autowired private StudentRepository studentRepo; } @Service public class StudentService { private StudentRepository studentRepo; @Autowired public void setStudentRepo( StudentRepo studentRepo) { this.studentRepo = studentRepo; } }
  13. Field Injection Quiz: which type of Injection in a Spring

    test? Constructor Injection 17 @SpringBootTest public class StudentServiceTest { private final StudentService studentService; @Autowired public StudentServiceTest( StudentService studentServ) { this.studentService = studentServ; } @Test public void shouldFindStudentById() { } } @SpringBootTest public class StudentServiceTest { @Autowired private StudentService studentService; @Test public void shouldFindStudentById() { } } demo: GreetingService part 2
  14. • Most annotations may be omitted using conventions over configuration

    JPA: Class-Table mapping @Entity @Table(name = "student") public class Student { @Id @GeneratedValue @Column(name = "id") private Integer id; @Column(name = "name") private String name; //… } id fname 1 John 2 Sam Table: student 18 demo: VisitService part 1
  15. @Transactional inside a SpringBootTest • Keep your test database clean

    so it’s ready for the next test! @SpringBootTest public class StudentServiceTest { @Autowired private StudentService studentService; @BeforeEach public void initialiseStudent() { this.studentService.save(new Student(null, "Sam", "Smith")); } @Test @Transactional public void shouldFindStudentById() { var student = this.studentService.findById(1); assertThat(student.getId()).isEqualTo(1); } } BEGIN ROLLBACK 19 demo: VisitService part 2
  16. Tab completion • Cursor: name came from the fact that

    it can autocomplete next to your cursor ◦ Still compatible with all VSCode plugins ◦ Uses Tab feature (used to be called Copilot++) 20 demo: LoggerTest
  17. Conclusion on Cursor and Java dev • Cursor is a

    great AI coding assistant • Java developers are facing a dilemma ◦ Give up on IntelliJ or use limited AI assistant ◦ Most likely it will improve in a few weeks https://forum.cursor.com/t/please-consider-a-jetbrains-plugin/17042/31 21
  18. We shall use Cursor to build a very simple pet

    service / API. What are we going to do? 23 In Scope pets-service order-service storefront notifications
  19. • Initial prompt: Let the tool build everything 24 1.

    Generate a NodeJs / Express / Typescript REST API implementation for a Resource Pet with the following attributes: a. id (number) b. name (string, min=3, max=20) c. tag (string , min=3, max=20, optional) 2. Ensure input fields are validated 3. Add tests with test coverage and ensure coverage is above 80% 4. Generate necessary steps to run and test the service
  20. We will be more specific about what we want 25

    • New prompt: You are a senior nodejs developer. implement the following requirement in full. Go through every step below and follow the instructions accurately. 1. write an express / typescript based REST API implementation for the openapi spec @pets_api_v0.1.yaml 2. use the structure shown below: … <snip> … 3. add pagination semantics with optional page and limit query params. default the limit to 1 and page to 0 4. add contract testing with coverage information. the test coverage must be a minimum of 80%. also, write through tests covering all api endpoints and scenarios 5. add necessary logging using winston 6. create necessary package.json and tsconfig.json 7. the api service will run on Nodejs 22
  21. We think it is generally went well. How did it

    go? 27 However, it is worth considering the following; 1. Keep an eye on (large scale) code changes (+/-) in short order 2. Go with incremental instructions / build 3. Look out for possible hallucinations - eg. including/omitting certain attributes from API resource, deleting test cases that errors out. 4. Don’t let the AI fix simpler issues - Cursor, for example can fix simple issues fairly well locally with its `Tab completion` feature 5. You own the code and the AI tools are assisting. So, make sure the code meets the requirements on security, quality, maintainability, scalability, etc
  22. We barely scratched the surface of what AI could do

    for software engineering. There are several possible next steps - 1. Add security (ex: JWT) 2. Add observability 3. Integrate other frameworks / tools 4. Use AI in other parts of the workflow - Code Review, for example 5. Use of enterprise-wide policies to govern what AI generates 6. Documentation 7. Deploy the generated code according to enterprise standards ... Possible next steps.. 28
  23. Supervised versus Unsupervised generation • Cursor is a productivity tool

    for developers ◦ Still needs to be supervised and improved • If you’re using VSCode already, just jump into AI coding assistants! • If you’re using Java or C#: it’s time to explore, things will improve fast 30 Be aware that AI tools are assistants, not replacements. Always validate AI-generated code and designs within the context of your project.
  24. Our resources • Java/Cursor demo: https://github.com/michaelisvy/cursor-spring • builder.io Cursor vs

    Copilot comparison: https://www.builder.io/blog/cursor-vs-github-copilot 31