What are some "Best Practices" you've applied recently?
A lot of what I've been doing is very obvious for most devs... But wasn't when I first wrote this particular code.
And a lot of it is stuff that's still tempting to ignore even with more experience, even when it's actively causing annoyance, but I'm always so much happier with code that's been cleaned up.
What are some of your favorite ways to refactor, polish, automate, and generally make code less hacky?
Stuff I've done lately, in no particular order:
* Get rid of stuff your dev tools don't understand. Don't just accept not being able to debug
* Heavy metaprogramming is generally in this category
* Logicless templates, or at least templates with less logic, keep code out of places the debugger can't follow
* Just use Pip, don't mess with sys.path and put dependencies in the repo where the linter doesn't understand them
* Don't do templating in languages the auto formatter doesn't understand
* Type annotations or static typing everywhere
* Schema validation: it doesn't just validate, you can also use the schema to generate UIs, use it to determine what keys to save from a larger superset, use it to fill in defaults, use it to strip defaults, etc.
* Schemas are also free documentation
* Use a Makefile or some similar tool, to gather up any scripts or snippets you will need, even if you're not doing C/C++. Don't just have a pile of scripts or a readme of snippets.
* Eliminate rarely used features that depend on obscure hand maintained middleware
* Don't go out of your way to add support for crappy hacky ways of doing things.
* Just say "Use a virtualenv, I will not make any effort to support not using one"
* Use standard common protocols and file formats
* Use VCSable text for small amounts of data where possible, not some crazy binary thing
* Use feature branches and general Git good practices
* Re evaluate your just kind of OK tools and see if there's something better that's come out
* If your UI looks bad, add whitespace.
* Don't act like you're building a new general purpose language. Add stuff for concrete use cases with complete workflows in mind, not vague "wouldn't it be cool if" ideas.
* Don't make 1000 lines of plugin APIs if it's only for one thing that could be a 10 line core feature.