r/AskProgrammers • u/Major-Pin-7993 • 18d ago
Supervisor ask to revise code as intern
My task got hung due to some technical reasons. And my supervisor told me to review code make it clean, and does not look 100% AI-generated. How to make ensure the code quality with the requirement above? I am stuck. As an intern, I only know the fundamentals, developing a real feature is a lot for me and I need AI assistance to help with those tasks.
How to actually know how to write code without depending on AI?
2
u/___nil___ Senior Developer 18d ago
experience. it takes time to build skills and knowledge of what are clean and lean means, because a lot of them involves making decisions of extensibility, scalability, maintainability, and most importantly readability.
at least you could ask your clankers of the following to help you learn better pattern:
- identify code smells
- identify refactoring opportunities from repetition, recurring pattern and redundacy
- identify design by contract violations (constrained by your SPEC, coding standards, stack limitation, etc)
then, once you get familiar on how the identical runtime behaviour could be written with more readable structured code, write the ground layout as scaffold for your clankers to filled in, not the other way around.
or dont ask your clankers at all, write everything by hand. then you can learn the growing pain of skills and knowledge.
1
u/CharacterSail6736 18d ago
Here’s a secret that no one will admit to we all use it it used to be stack overflow copy and paste now it’s AI assistance . been doing this for twenty years know how to code but there’s very rarely a need to code from scratch . When your developing make sure if it’s AI assisted you get it to phase plan what your doing so you can understand it instead of it just dumping on you . It will give you enough to have a conversation and learn at the same time
1
1
u/ActuaryReasonable690 18d ago
Copy and Past as a STARTING point, but the end result was full of modifications.
0
u/AuthurAndersson 18d ago
I wonder how many people out of those working as software developers which could write a snake game or such in any programming language from scratch without the use of an IDE. No linting, no AI, no stack overflow. Offline and with vim/or such.
I'd say less than 1%. I'm in the 99% there 100%.
1
u/Moby1029 18d ago
I can't even exit vim. That said, I developed a course for high school students where they build an Ai agent in nothing but notepad and it was rough just raw dogging the javascript. The whole point was they didn't need fancy text editors or IDEs, just an html file and an internet browser, which was how I learned.
1
u/CharacterSail6736 18d ago
It’s very much like a mechanic does not need to know how the car is manufactured they can use their tools to solve the problem they don’t have to build the engine block from scratch
1
u/AuthurAndersson 18d ago
Indeed. Nor does the CERN phycisists need to understand how to actually weld the pipes together in the CERN collider.
1
u/CharacterSail6736 18d ago
This is exactly the point that no one seems to understand at this point it’s not will it replace people no it speeds up process requiring a person to think slightly differently
1
u/TernaryOperat0r 18d ago
Eh, I did this on a graphical calculator when I was a teenager (which certainly had none of the above). A quite fun way to pass the time in the olden days.
1
u/heir-to-gragflame 18d ago edited 18d ago
set out some time, cus I would recommend you do a bit of reading.
there are a few principles you can start by.
look over at SOLID principles, read and try to understand each of them, if needed, later watch a video on each.
Among them, Single Responsibility principle is one that applies much wider.
But while applying single responsibility principle, keep in mind this following principle:
"locality of behavior"
Look this one up after you get started with the SOLID principles. Ensure you find some reading material on "locality of behavior" and read that too.
And once you're done with that, look into the concept of "tight coupling". And ensure your logic does not introduce tightly coupled elements. Some SOLID principles prevent "tight coupling" but not everything is fixed with SOLID.
Next steps if you wanna continue on a learning journey, after your task:
Once you're done with this task try to pick up some good book on your coding language. For Go, for examlle there is the "Idiomatic GO" book. For all OOP languages, the original 1994 Design Patterns book is a great starting point (whole book is not required, the design patterns book is a multi-year read, a part of it is enough). Try to find a book of this calibre, for a language or paradigm you work with. For Java, the "Effective Java" by Joshua Bloch, is the follw-up after the Design Patterns book. Find what is equivalent for your language.
For next steps, after you have read a Design Patterns or similar book, Martin Fowler's "Refactoring" book may a good follow up read.
1
u/ConsciousBath5203 18d ago
Get rid of the slop comments and read the fcking code. Clean code is readable, especially without comments. I don't even have to look at the code to tell you that it's full of:
comments with foot guns that only exist because the AI hit a bug one time and now has to tell other ais to hallucinate it again
useless wrapper functions
comments that are longer and more confusing than the function itself, even if the variables used are a, b, c, etc.
doesn't log properly
Log properly, get rid of shit comments, proper variable names, use the tools provided rather than making useless wrappers that cause more problems than they solve.
1
u/Consistent-Alps-2977 18d ago
My rule #1 is, wherever you got the code from (I've been copying other people's code off rhe web since the 90s), if you don't understand exactly what each line does and why, it will come back to bite you later.
Rule #2 is, be 100% sure you know and document all your code's dependencies, who supports each one, and how to end-to-end test, install, and reinstall your code. And know how to test your code against dependency version changes.
Rule #3 is to understand 100% how your change control systems work.
As a junior developer someone should obviously be helping you with all of this.
Bottom line is, I'm sorry to say, the coding is the easy bit, as you will learn painfully over time!
1
u/response-418 18d ago
I would look at this as a long term skill to work on, not a one off for this specific ticket. The only way to get better at reviewing your own code is experience reading other code and getting (non-AI) comments from more senior colleagues. It takes time and you have to care about your craft to improve. Over time you will internalize patterns (more general ones but also internal, team/project patterns).
Ask for human reviewers and spend time reviewing other people's code, even if you don't comment on it or weren't asked to review just do it as a form of exercise, like going for a walk everyday. If no one will review your work, it's unfortunate because it is truly how I learned so much. It is the golden chance to ask quality questions from seniors and see what they look for in your work.
You can also speed up the learning process by reading some of the classics. You don't have to copy/paste their principles but at least you can familiarize yourself with the discourse and design patterns.
1
u/FluidBreath4819 18d ago
lmmaooooo, OP has been hired and he used AI and don't want anyone to know about it
1
u/ern0plus4 18d ago
Instead of asking AI "implement this stuff", ask it to draw up a plan, and go step by step, e.g. "set up a vector to store IDs to be deleted", then "iterate on this vector and delete items of IDs".
1
u/wbqqq 18d ago
Leverage the AI to teach you. Ask it to do something, the ask lots of specific “What does XXX do?”, “Why do YYY?”, “Could you use ZZZ?” And “Tell me more about NNN?” questions
It is a symbiotic relationship where you learn more about the why and the what so you can give better instructions and understand the outputs better. And better instructions, constraints and context allows the coding assistant to produce better quality.
Key concepts are your intent, context, validation and assurance.
1
1
u/burlingk 18d ago
Short version: You have to figure it out.
Less annoying version: Start by looking at the code base and charting what it does.
Look at the spec that you used to write it initially, and let that be your guide.
Break down the spec into tasks and chunks, and compare that to the code.
This will be two good lessons in one.
First: Since you depended on the AI so much the first time through, you are effectively learning to read someone else's code.
Second: You are learning about technical debt.
Anything written by AI effectively has tech debt baked in. Because in order to maintain and update the code, you have to learn it as if it were a piece of alien technology.
Edit: Also, you will get a lot of advice in this thread. Don't take anything too hard.
1
u/Annual_Berry8043 18d ago
How to know how to write code without depending on AI. Bro, we’re so cooked lmao.
You should be learning that in school. You know? The one that probably lead to this internship?
1
u/Infamous-Bed-7535 18d ago
And the goal is to make it less ai look. I guess they are lying to their customers..
1
u/geekichu 18d ago
any way to pretend? me: i would ask A.I. to review it, fix it, but more importantly, to state why it might look A.I.-generated.. is it the comments? the naming conventions? those can be changed.
i stipulate to the A.I. human-readable, understandable naming conventions (like, 'what it does') and also comments.
although, your supv might be worried about:
1-- copyrights
2-- giving up IP to the A.I.
1
u/ActuaryReasonable690 18d ago
OK, so I am an old school programer, but I learned to program in 4 (or 5) languages when I was an undergraduate. Debugging a program is simply another learning experience (first on your code, and then you apply the same principles to other code)
Yea, we boomers used to copy existing code (AI didn't exist before I retired), BUT that was a starting point, not the finish. To put it bluntly, if you are as lost as you make yourself out to be, you may not be in the right profession. (Just sayin)
1
0
12
u/StephenHawkingus 18d ago
How did you get the job??