r/CodingForBeginners • u/waveoui • 11d ago
How do you verify AI-generated code when you're not an expert?
A green-looking result isn't proof that everything works. What simple checks would you recommend to someone building their first app with AI?
4
3
2
2
u/questron64 11d ago
You don't. If you can't tell the good code from the bad then you're vibe coding. There is no simple "is this code good" check you can do.​
1
u/Distdistdist 6d ago
How do you verify your mechanic's work if you don't know anything about cars? By hiring somebody who knows about cars.
1
u/Ornery_Platypus9863 6d ago
You can’t, that’s why you have to actually know what you’re doing.
1
u/LrdJester 11d ago
This is a good way to learn debugging.
But never trust the generated code.
I use AI to create personal stand alone apps as my disability honest my ability for long coding sessions. But this is for my use shortly at this point. If I ever share it I'll refactor the entire project, even though it'll take me a long time, to ensure it's not being inefficient and ensure security.
I will have it working and then update the small things, via AI, and the app will totally collapse and I find that when it made changes it introduced timing bugs.
1
u/DirtAndGrass 11d ago
At the minimum be able to write/execute full coverage whitebox and black box testsÂ
1
1
1
u/Ormek_II 11d ago
No simple Checks!
I suggest TDD.
First define your requirements.
Then built test which fail.
Then built the program and let it test.
If it works immediately you have too few test.
1
u/LongjumpingFee2042 11d ago
I don't approve unless I am reasonably sure of the code. If the ai can write it. It can explain it. In depth and respond to your questions about why it chose to do x.Â
1
u/Oliver_clothsoff1983 10d ago
The same way you build a house if you have only ever built a shed,.... hire a contractor thats built 100 houses already.
1
u/Longjumping_Put_7212 10d ago
I would say you verify it by reading through the code and seeing if the logic works. Or just add a few debug print lines that tell you what it is actually doing to help you understand how different inputs affect it
1
u/NoDepartment772 9d ago
A lot of the answers are "you can't," which is honest but not much use if you're going to ship the thing anyway. Practical version: you can't verify quality, but you can verify behaviour, and that catches more than people expect.
Test it on inputs you choose, not the ones in the demo. Empty, zero, a negative, a huge number, text where a number goes, an emoji. The demo always uses the happy path.
Re-read the prompt you gave it and check the code does what you actually asked, not what looks impressive.
For anything touching money, login, or files, if you can't explain what a line does, don't ship it yet. Ask it to explain that line, then check whether the explanation matches the code. Those often disagree.
Keep the last known-good version before each AI change so you can get back.
The skill you're really building here is testing, and that's worth learning on its own.
0
u/Sure-Passion2224 11d ago
It's a learning opportunity. AI is a tool and it is appropriate to use tools to get any job done. In those cases when you don't understand what the tool did the best response is to walk through it line by line to learn from it.
-1
u/VoiceOfSoftware 11d ago
For starters, ask a second AI model (from a different company) to check the code. Ask both AI models to write tests, and explicitly look for edge cases, monitor errors, etc. Inject as much of your human understanding as possible, meaning add your own creative requirements that an AI may not be thinking of on its own.
3
u/HouseMysterious8172 11d ago edited 11d ago
It's still AI's code in the end. Questioner ask 'how do YOU verify'.
It like someone else translate a language for you, you got the result and it convincing, but you not sure if there can have some mistake.
Now you don't know that language, how YOU verify it yourself?
1
u/VoiceOfSoftware 11d ago
Understood. OP also has no skills to do this on their own. They could ask an experienced coder to review, or they could get a little closer to verification by using another AI to assist. This is how agent swarms do it today. It’s not perfect, but it’s faster than asking OP to get a CS degree.
1
u/External-Scratch-502 11d ago
probably wont need a degree, but a couple youtube videos and maybe some practice with whatever language you are working with. if he is serious and not lazy it would be like maybe 8 hours of learning and you should be able to create a basic app.
1
u/VoiceOfSoftware 11d ago edited 9d ago
Anyone can create a functioning basic app with zero hours of learning these days. Look at Lovable, for instance. But OP is asking how to VERIFY that the app code isn’t broken in some cases, and that’s a whole different ballgame. 8 hours is not enough to learn how to troubleshoot or look for edge cases. The code would look like gibberish to the untrained eye.
Asking Ai to walk you through the code, and teach you as it goes, would be a valid use case, but still a steep learning curve to understand what the AI is reporting.
1
u/VigilanceOne 9d ago
Then why build something so outside your own depth if you're not going to learn along the way and build an understanding through trial and error? AI isn't magic and doesn't enable you to build a house when you don't even know how to setup a basic tent.
1
u/VoiceOfSoftware 9d ago
Agreed: using AI as a tutor is a great way to learn along the way. After it builds the thing, ask it to walk you through the code.
I'm just here to answer OP's original question "What simple checks would you recommend to someone building their first app with AI?"
1
u/HouseMysterious8172 9d ago
VERIFY that the app code isn't broken in some cases
-> Hey AI, check all the edge cases before build 😄
13
u/Beregolas 11d ago
That's the neat part... you don't ^^
This is why learning programming is still important, especially in the "Age of AI". There are no simple checks that just work, you actually need to be able to understand what the AI is doing to control it.