While programming i am always afraid that what i do, even if it works, is unsafe/deprecated (stuff like using the mysql API in php instead of mysqli or PDO).

I was asking myself how does someone keep up with the best practices for a certain field/programming language?

thanks

EDIT: Thanks to everyone that was exaustive

  • @fidibus@lemmy.161.social
    link
    fedilink
    63 years ago

    Honestly? You can’t. You can just learn new things and then use them.

    Many people say oh but it actually should be done this way (some standard), but in other places they just write spaghetti code for production. So this should only means that it results in better code. Doh, learning makes you better?!

    So it’s nice to develop test-driven, but if that’s too hard for you now don’t worry, many people can’t do it.

  • Seirdy
    link
    43 years ago
    • Official docs might mention them
    • Static analyzers/linters typically have docs in which they describe rationales for their rules
    • Crack open a book or two
    • Subscribe to RSS feeds for blogs from reputable people involved in the language’s development
  • @glennsl
    link
    3
    edit-2
    3 years ago

    deleted by creator

    • Ephera
      link
      43 years ago

      Yep, best practices imply that there’s worse practices, and that it’s common to choose wrongly.
      Your programming language and tooling should make worse practices harder to choose, or clearly notify you that there’s a better way.

      Knowing these best practices yourself is dead weight and you should ideally choose a language which doesn’t require extensive best practices, and/or try to upgrade the tooling that you’re using.

      • Ephera
        link
        43 years ago

        Or to give maybe a more direct example: My company paid for a security training which is available for different programming languages.
        I chose Scala, because that’s what I mostly code in, and because of that, all the code examples are just the goofiest thing.

        “Here’s a really dangerous security vulnerability and you need to write extra code to prevent this. Well, in Scala, this isn’t the case, the default is actually correct, but let’s just assume a previous programmer explicitly wrote out two lines of code to allow the security vulnerability for no reason at all. Now, how do we fix this? Oh yeah, we just delete those two lines.”