Besides some of the very, very obvious (don’t copy/paste 100 lines of code, make it a function! Write comments for your future self who has forgotten this codebase 3 years from now!), I’m not sure how to write clean, efficient code that follows good practices.

In other words, I’m always privating my repos because I’m not sure if I’m doing some horrible beginner inefficiency/bad practice where I should be embarrassed for having written it, let alone for letting other people see it. Aside from https://refactoring.guru, where should I be learning and what should I be learning?

  • monomon@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    3 months ago

    This might be contrary to some, but i recommend diagramming! Can be anything from paper doodles to d2 to full blown uml diagrams. They help you stay focused, and aware of the program’s data dependencies.

    Regarding code practices - read code. If you use a library for something, dive into its code. This can be beneficial in many ways - you observe the style they used, you understand better how the library works (documentation rarely contains enough detail), and you see how libraries are structured, which is often lacking in newbies.

    Learn your language’s idioms. They can reduce complexity, and are usually more readable to people with experience in the given language.

    Finally, don’t sweat it too much. The more you write, the better you’ll become, so just do it. New problems lead to new insights.