Major refactoring needed from AI generated code

For the past week, I have been heavily interacting with some AI tools for my coding needs. When I usually need a solution, I reach out to Google, get some ideas from there, and try to implement it on my own. But then I thought, why not interact with Chat GPT or similar AI and get the answers from them? The interaction was excellent, and I was even able to get code samples from the AI.

Initially I started the discussion only as a brain storming session but then later I thought maybe AI it can give me the code so I wanted to give it a try by asking but to my surprise, I was right that AI was able to generate the code and give it to me and it was very close to perfection. I started testing the code and had to make some tweaks here and there and the code was suitable for me.

Source

Now comes the interesting part. I had to do a lot of back-and-forth communication when I wanted some enhancements in the generated code. First, I had problems with linting, and I asked GPT to lint the code and provide me with clean code with no unused variables in the code. Even till here, GPT did the perfect job. But then I found some variable hanging around. When I asked GPT when there was a variable hanging around it said it was for a feature that I requested long back. One thing that I understood was that GPT does not remember exactly what I want and serves me accordingly. It can pretend to act brilliant, but it isn't.

For multiple feature enhancements, I had to ask multiple questions to GPT and come up with the final code. The exact problem happened here. Just because I asked so many questions about different features, GPT somehow misunderstands that I want a mix of everything. Sometimes I might have asked about a feature, but would have implemented the code with a different logic. GPT confuses both things, and the final output given by GPT usually has some code references that are a mix and match of both requests. This is something that is not very great when it comes to getting answers from GPT.

For security reasons, it is very important to review the code generated by GPT line by line. That's when we might realize that a major refactoring might be required, both logic-wise or readability-wise. We might see obvious things, but AI makes those changes only if we ask it to.


If you like what I'm doing on Hive, you can vote me as a witness with the links below.

Vote @balaz as a Hive Witness

Vote @kanibot as a Hive Engine Witness



Posted Using INLEO



0
0
0.000
6 comments
avatar

Hmm I'm not sure chatgpt is the best for coding, my colleagues used an other one, i can't remember which one now and it did a very good job without much fix needed

0
0
0.000
avatar

These days there are multiple such AI tools available.

0
0
0.000
avatar

It's exactly like that. Many problems are being solved with ChatGPT and people are getting to learn a lot. Both these software are making people's lives easier.

0
0
0.000
avatar

This post has been manually curated by @bhattg from Indiaunited community. Join us on our Discord Server.

Do you know that you can earn a passive income by delegating to @indiaunited. We share more than 100 % of the curation rewards with the delegators in the form of IUC tokens. HP delegators and IUC token holders also get upto 20% additional vote weight.

Here are some handy links for delegations: 100HP, 250HP, 500HP, 1000HP.

image.png

100% of the rewards from this comment goes to the curator for their manual curation efforts. Please encourage the curator @bhattg by upvoting this comment and support the community by voting the posts made by @indiaunited..

This post received an extra 20.00% vote for delegating HP / holding IUC tokens.

0
0
0.000
avatar

I was surprised few days ago when I was told that even AI has started to program some code and it is actually getting evident. Every day, we are getting close to it much more than we can expect

0
0
0.000
avatar

Combining AI assistance with critical human oversight ensures better, safer, and more tailored coding outcomes.

0
0
0.000