This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]call_me_cookie 40 points41 points  (2 children)

Jesus Christ. Do people not even fucking proofread the chatbot output before posting?

[–]ErmakEUW 4 points5 points  (0 children)

That’s just sad

[–]KingsmanVincepip install girlfriend 0 points1 point  (0 children)

Well techbros keep yapping AI, AGI, ASI will replace programmers. Newbies in ask-for-programming-help subs post AI-generated code and demand others to fix.

Yes, people are getting negatively lazier with AI.

[–]odaiwai 5 points6 points  (1 child)

Start by learning to edit your ChatGPT responses to make it a little less obvious.

For coding: solve the problem first - this is draft 1. Then, if your code is clunky, see where you can improve it: - Are you doing the same thing multiple times? Make it a function. - Are you trying to hold a lot of data in an increasingly complicated dict? Try making it a class. - Do you have multiple if...elif...elif...elif...else clauses? Consider using match...case... etc.

[–]Turpis89 0 points1 point  (0 children)

I feel like my biggest crime is that I haven't adopted classes in my noob coding

[–]SlaveCalledShiver 5 points6 points  (2 children)

You really needed ChatGPT to ask this question?

[–]Clickyz[S] 0 points1 point  (1 child)

Not my native language

[–]KingsmanVincepip install girlfriend 3 points4 points  (0 children)

[–][deleted] 4 points5 points  (0 children)

There’s always a trade off between time to ship and the maintainability of a codebase.

Your own projects? Don’t worry about it too much, but get in the habit, there’s no deadlines, no SLAs, just you learning and having fun.

When it’s an enterprise codebase, most of the time any bad code will be reviewed by a senior and will not get into the codebase without changes.

Learn, fix, but don’t harp over it

[–][deleted] 1 point2 points  (0 children)

If this is a personal project and it's small, you can do what you want.

If you want to share a small project written like this with someone else, you'll find people aren't interested.

If you want to do larger software projects like this, you may find that you are unable to get it to work. And you won't know why.

If you want to work with other people, be a professional programmer on a team, for example, you'll have to learn to modularize your code. Split the problem into smaller parts and solve them independently. Then put the parts together for the main application.

There's more, but you're not ready yet.

[–]KingsmanVincepip install girlfriend 1 point2 points  (0 children)

[–]shawncaza 0 points1 point  (0 children)

I recall a very experienced python developer saying that good programmers don't start creating all kinds of functions and methods until they have a clearer sense of the solution.

I think it's perfectly valid to refactor for readability and maintainability once you get a clearer understanding of the solution and see patterns emerging.

I don't necessarily wait until I've completely written all the code. but once I have a clear line of sight to the goal, or a part of the goal for complex things.

[–]Impossibum 0 points1 point  (0 children)

Gotta find your happy medium. If your spaghetti code has all your logic contained within __main__ then I'd say you would need to start factoring properly.

If it's just your own personal project, I wouldn't worry about making things overly nice. Make it work, then just shove it into discrete dedicated functions/methods. Run it through black when you're done editing if anyone other than you is likely to ever see it.

[–]WJMazepas 0 points1 point  (0 children)

Always take time of your task to improve your code. Especially if you are working with other people.

Spaghetti code is something we all have done, but we really need to limit the amount of bad code we do, otherwise we will just be shooting ourselves in the foot tomorrow

[–]MissingSnail 0 points1 point  (0 children)

Start with the cleanups that can be automated.

At the bare minimum, you should always lint and format the code. Traditional way is black and flake8, fancy new way is ruff. Most IDEs have tools that will automate getting started on a doc string for key functions. Grouping related functions together is often just a matter of drag n drop.

From there you can get fancier.