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?


EDIT: Thanks to everyone that was exaustive

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.

  • 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

deleted by creator


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.


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.”

General Programming Discussion

    A general programming discussion community.


    1. Be civil.

    Other communities:

    • /c/rust
    • /c/python
    • /c/powershell
    • /c/haskell
    • /c/fpcomplete
    • /c/cpp
    • /c/c_programming
    • /c/julia
    • 0 users online
    • 3 users / day
    • 38 users / week
    • 64 users / month
    • 125 users / 6 months
    • 2.63K subscribers
    • 747 Posts
    • Modlog