DEV Community

Cover image for When dealing with requirements using Trae, programmers should no longer refer to themselves as “code farmers” in the future.
Jinu Kim
Jinu Kim

Posted on

When dealing with requirements using Trae, programmers should no longer refer to themselves as “code farmers” in the future.

The free download link for Trae used in this article is:https://www.trae.ai/?utm_source=juejin&utm_medium=juejin_trae&utm_campaign=medium_article

Introduction Recently, I received a business requirement. The general background is as follows: The business background is that our product is connected to a third — party system. I need to provide interfaces to allow the third — party to import their dictionary table data into our database. For each dictionary table, only new additions and deletions are considered. It’s a very simple CRUD requirement. There’s no complexity for me at all, but it’s extremely cumbersome. With 10 tables and only considering new additions and deletions, I still have to write 20 interfaces, which is very time — consuming. Each table has many fields, and the database has non — null and length restrictions. You must do a good job in verification; otherwise, if there’s an error, you’ll be the one to be held accountable. As a senior backend programmer, I’ve always been resistant to this kind of requirement because it’s all physical labor, including development, testing, and going live. There’s no technical content and no room for improvement. Every time I’ve done similar requirements before, I’ve deeply felt like a migrant worker. In fact, I’ve always wanted to integrate AI into my daily development work. However, I’ve always had this mindset: if I can finish a task in 10 minutes, why spend 20 minutes exploring how to use AI to get it done? So I’ve been procrastinating, and I haven’t used AI much in my daily development. But this time, the workload was still a bit large. With so many interfaces and tables, and having to sort out the parameter verification, I couldn’t afford to waste this time. As a former ByteDance employee, I also noticed that Juejin is promoting Trae. I must embrace and support the tool of my former employer. So this time, I decided to give Trae a try. This requirement itself is not complicated; it’s just simple CRUD. Currently, I’ve already implemented all the basic functions. I’m recording the process of this usage, and I also hope that everyone can use AI as soon as possible to relieve their work burden.

Installation of Trae

The download link is provided here. Currently, it only supports macOS. Windows users may need to wait a bit. I estimate that Windows support will be available soon. I blindly guess that it’s because most of ByteDance’s developers use Macs. It might really be not that easy to find Windows developers.

https://www.trae.ai/?utm_source=juejin&utm_medium=juejin_trae&utm_campaign=medium_article

Currently, Trae offers two modes, namely Chat and Builder.

It seems that Trae can do quite a lot. My goal is to make modifications to an existing project, so I chose the Chat mode. The Builder mode is mainly for building a project from scratch. If you need to create a page or something, you can use it, but I won’t use it this time. Currently, code completion and refactoring are standard features of all AI tools. This time, I don’t just want it to complete code; I want it to help me finish my work. The models used are Claude — 3.5 — Sonnet and GPT — 4o, and they are currently free of charge.

Code Generation

The first step, of course, is to create the entity classes. At first, I created the entity classes on my own and copied the previous fields over.

The AI directly wrote the interfaces and Mappers. However, I realized that there were still a bunch of tables, and writing the entity classes by myself would be too complicated. Oh, right. I also had to perform some non — null and length validations. So I thought it would be better to just let the AI handle this task. The actual fields in the tables are very numerous, so I won’t list them all here.

Thanks to it! The AI solved the most headache — inducing parameter verification problem for me. My interfaces are provided for third — parties. If I don’t perform the verification, there’s a high probability that errors will occur when inserting data into the database. It could be due to exceeding the length limit or the database’s non — null verification. The AI has added all the necessary annotations, which saves me a lot of trouble.

It has considered quite comprehensively. It performs much better than I did when I just graduated and started working.

Then it’s all about repetitive work. I just need to feed the table structures I need to it one by one. Here, I’ll skip the screenshots of other table structures. After creating the entity classes, I can take it easy, but it can’t. Come on, write the interfaces and other related code for me.

I didn’t use any complicated prompting words, but it did a great job overall. It also took into account the subsequent tasks. It seems to have considered the output limit based on the context, as there are many methods marked as “TODO”. Let’s just keep going.

Next, it’s time to write the simplest CRUD code, including the Controller, Service, Mapper, and XML files. All that’s left is to copy and paste to finish the task.

AI Code Fix

Although the code has been written, there are some errors. Of course, even if I were to copy — paste the code myself, there would definitely be errors. For example, here the AI generated PostMapping, but the Mapping we use is encapsulated by the company’s components, which is inconsistent with the previous Controller code.

Trae offers an AI repair function. When you click on this function, it can automatically recognize the intention for repair. Based on the context of the code, it understands what I want to modify. I’m very satisfied with it.

Although I could fix it by doing a full — scale replacement myself, it just feels good that it can correct the errors on its own. What I mentioned above are all about code generation work. Actually, there were some components like EasyCode that could also help us with this before, but this is still a completely different experience, and we can also let it do more work. ### Intention Recognition There is another feature that I find extremely impressive, which is intention recognition. For the interfaces provided by a Spring Cloud project, the backend always has a logic for returning results after fallback. That is, we need to write an OpenApiNewFallBackImpl class, which contains fixed error — return information. The methods in this class need to be consistent with those in OpenApiNew. This time, I added more than a dozen interfaces. Naturally, I also had to add more than a dozen corresponding interfaces to OpenApiNewFallBackImpl. Previously, I always copied them manually and had to write the corresponding method names, which was really annoying.

Trae can provide context. Initially, I selected the OpenApi file with the intention of asking it to help me fix the code errors.

However, accidentally, I sent the request before I had a chance to write the prompting words. To my surprise, it directly recognized my intention. Well done! It even spared me the trouble of writing prompting words.

In Conclusion The above is the entire process of using Trae to complete one of my own requirements, which took a whole day. Finally, I’d like to share my thoughts. This article describes a scenario that backend programmers often encounter. If it were five years ago, I would definitely have carefully coded each interface. But now, I must learn to leverage the power of AI. How should we embrace AI? Should we start asking AI instead of searching on Baidu when we have problems? Should we learn how to write good prompting words? Or should we study the principles of AI in detail to become experts? In my opinion, we should try to use AI for all our work. Only in this way can we truly embrace AI. In this process, you’ll realize what AI can do and what it still lacks the ability to do. Only then can you make judgments about future trends in advance and find new opportunities for yourself. In my view, the biggest change AI brings to backend development is that it eliminates the “manual labor”. Programmers often self — deprecatingly call themselves “code farmers”. I think we don’t have to use this term anymore. What we do is all mental work, and we can leave the manual labor to AI. However, I’m not fantasizing that AI can handle all the work for now. I also hope this situation comes later. And I always believe that humans should be in control of systems and programs, and AI is just an assistant. But since AI can take over those time — consuming and laborious tasks, isn’t it better to use the remaining time to write some articles for everyone?

Top comments (0)