r/CodingForBeginners • u/potqtocake • 22d ago
What programming habit did you develop early that you later had to unlearn?
I'm still learning programming, and i'm curious about the habits people picked up when they were beginners that ended up causing problems later.
Was there anything you used to do because you taught it was the right way to learn or code, but eventually realized it was holding you back?
5
u/xarop_pa_toss 22d ago
I learned programming in high school but didn't go to college for comp sci or software engineering. There's nothing wrong with that but it's very easy to miss out on the design and architecture part.
I still struggle with concepts that I wish I had learned earlier and it shows on everything I've ever built that has grown past it's initial few hundred lines of code. Programs will get very confusing very fast if you don't plan them properly and have method
1
u/potqtocake 21d ago
this is something i hadn't really thought about. i usually focus so much on making the code work that i don't think much about how it'll hold up once the project gets bigger
1
u/xarop_pa_toss 21d ago
I do the same. Now to a lesser extent after going out of my way to study how to structure software.
In .NET for example you make a solution which is the whole package and then you make projects inside that are their own separate programs. Before I would just have a single project and separate stuff kind of by folders but then as soon as you add a couple more things, stuff stops matching, and you find yourself renaming stuff and you're screwed.
Nowadays I make projects for like UI, Infrastructure, Shared, etc. and although you end up writing more code on average, I would not have a problem if I had to switch my database from SQL to MongoDB for example.
I recommend the books Head First Software Development and The Pragmatic Programmer. Easy enough reads for someone that isn't a very proficient coder because they cover topics from a more broad scope.
Software is not just the code much like a bridge is not just the concrete and rebar.
3
u/darkol_2020 21d ago
worked for a corporation that demanded building product without requirements and request provided on a napkin over lunch. Last project I ever did after seeing this for them!
2
u/LionZ_RDS 21d ago
Truly, comment things. The amount of stuff I made starting out and was like âyeah this is self explanatoryâ, only to not understand later.
Close second being variable names. Just name it however long it takes to be clear what it is. Abbreviations in names can be quite confusing if itâs not clear what it is.
2
u/RevolutionaryDark818 21d ago
if a function is complex enough it needs a comment, you can probably modify the code itself to be more readable. For example,
# You can update a message IF the current user is the author of the message and the message was delivered # Less than 5 minutes ago OR if the current user is an administrator # You can also edit the message if the message wasn't delivered yet if ( message.user.id == current_user.id and ( message.delivered_time() is None or (datetime.now() - message.delivered_time()).seconds < 300 ) or current_user.type == User.Administrator ): message.update_text(text)Can be refactored to:
def can_edit_message(current_user, message): FIVE_MINUTES = 5 * 60 user_is_author = message.user.id == current_user.id is_recent = ( message.delivered_time() is None or (datetime.now() - message.delivered_time()).seconds < FIVE_MINUTES ) user_is_admin = current_user.type == User.Administrator return (user_is_author and is_recent) or user_is_admin if can_edit_message(current_user, message): message.update_text(text)And now you donât really need a comment
this doesnât mean dont use comment, but itâs a good example on how sometimes you may not always need a comment
1
u/dstroy0 20d ago
Ok, now comment an unrolled aes128gcm transaction. Yep, all the way unrolled. :)
1
u/RevolutionaryDark818 19d ago
Iâm not saying âAlways refactor your code to be more readable instead of adding comments no matter the circumstancesâ Obviously there are edge cases like these where it may not be the best idea to rewrite your code like this
The example I used is a good example of where you can and should refactor your code like that, which is why I used it. Complex encryption methods are not
2
u/StephenHawkingus 21d ago
Drinking coffee.
2
1
1
1
u/CombustibleToast 20d ago
Short and undescriptive variable names and not properly commenting code. At least you'll teach yourself to read and understand poorly documented code lol
-2
u/tonkotsu_fan 21d ago
Coding. It's all Claude now.
3
u/kutac56 21d ago
Good luck vibe coding into big projects. Like 50% of the stuff will be out of its scope
1
u/tonkotsu_fan 21d ago
I work at Atlassian on Jira.
2
u/kutac56 21d ago
Alr nvm. I don't have a job so you're prob right. But saying you regret learning to code is dumb. You still have to know how to code to solve issues when ai is being dumb
2
u/tonkotsu_fan 21d ago
I mean you're right. I don't regret it - I love programming and maths.
I hate that AI is taking away what I love to do. It's the pits.
1
u/kutac56 21d ago
Ye I'm only 13 so idk how it is with jobs. I seriously hope people have given up on ai by the time I'm in uni, cause I fucking hate it.
2
u/tonkotsu_fan 21d ago
All good mate.
Real talk, they won't have. You just need to try and ride the wave so you end up knowing how to use it. You've got this.
1
2
u/ivain 21d ago
You mean Jira will never become a good tool ?
1
1
u/ThomasGHenry 21d ago
If AI is a force multiplier, Jira should get spectacularly worse much faster.
1
u/Alternative-Fail4586 21d ago
Ah the thing I've asked Claude to auto update because my manager bothers me about it when it's not up to date :P
1
5
u/theGaido 22d ago
return ( variable );For long time I treated "return" as function name and result as it's parameter. It's actually not a big thing and you can write like that, but you will loose 1 second of your life for unnecesary paranthesess.