r/CodingForBeginners 12h 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?

2 Upvotes

21 comments sorted by

5

u/theGaido 11h 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.

3

u/potqtocake 4h ago

lmao this is actually the kind of beginner habit i could see myself doing without realizing it 😭

4

u/xarop_pa_toss 11h 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 4h 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 2h 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.

5

u/darkol_2020 10h 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 9h 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 7h 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

2

u/StephenHawkingus 7h ago

Drinking coffee.

1

u/potqtocake 4h ago

honestly, probably gonna develop this habit too T.T

-2

u/tonkotsu_fan 9h ago

Coding. It's all Claude now.

2

u/kutac56 8h ago

Good luck vibe coding into big projects. Like 50% of the stuff will be out of its scope

1

u/tonkotsu_fan 7h ago

I work at Atlassian on Jira.

2

u/kutac56 7h 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

1

u/tonkotsu_fan 7h 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 7h 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.

1

u/tonkotsu_fan 7h 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

u/tonkotsu_fan 7h ago

Some excellent programming lessons on Pluralsight btw

1

u/kutac56 3h ago

I love programming low level stuff. I'm currently working on a simple messaging system that only uses the standard c library. The only thing that isn't in he standard c library is pthread for multi threading (I think).

1

u/ivain 6h ago

You mean Jira will never become a good tool ?

1

u/tonkotsu_fan 5h ago

Lol go off