Still some of the best advice for programmers:
Don't be clever. Be obvious.
@fribbledom I spent a ton of time this week digging in the Git history for a string that was interpolated but could have been hardcoded. Not fun.
I never did find the code I was looking for.
@fribbledom i'm more from the "it was hard to write, it should be hard to understand" school of thought myself ;-)
@fribbledom I went through a period of time when I fought myself on intermediate variables in calculations, but man it's nice to be able to step through (or even console.log) those results.
At this point I most often consider what the intermediates are and if it makes sense to inspect them and if they can be given a proper name. Sometimes I change operations around a bit just to get meaningful intermediates. I think it helps read, too. :)
return foo(x, y, bar(z, other_stuff))
Sometimes, if the symbol names are too long:
def some_func(x, y, z):
that's what I mean by "one or two lines." If it grows beyond that, context is lost and/or becomes harder to change with evolving business requirements.
def can_we_do_the_thing(policy, user, agent):
policy_status = api.isPolicySetUp(policy)
allow_override = user_is_cool && some && business && logic || other_case || yet_another_case
agency_status = agent.Agency.Status == 'yep'
return (policy_status && agency_status) || allow_override
@gws @tewha @fribbledom
Forth programming practice suggests that we should never deal with more than three items on the stack at any given time. This "rule of three" seems to be useful as well in non-Forth languages too. If you need 3 or more elements in a single expression, that's a smell that you might want to refactor that code.
@fribbledom those who want to be "clever" have not yet learnt that that does not demonstrate their skill.
Being obvious is far harder!
1. write comments that describe your algorithm with pseudocode
2. implement EXACTLY what those comments say
3. stop programming. you are done. do not try to improve it.
@fribbledom that's actually good advice for anyone designing something to be used by other people. the more obvious and simple it is, the easier it is to pick up and use properly.
@fribbledom If you must be clever, document the shite out of it, and be clear with the how and why of your cleverness.
Server run by the main developers of the project It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!