I have several thoughts that don't have a coherent through-line, so I'll proceed and hope coherence comes.
One of the concepts in David Allen's Getting Things Done is using external memory. In fact, that's the only part that stuck, and I'm eternally grateful. I've found that taking notes by hand helps them "stick", which I credit to years of pre-computer education, but follows your NPR link.
# writes a random color in hexidecimal RGB format to STDOUT
def createColor
hexadecimalIntegers = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]
color = hexadecimalIntegers.sample(6).join("")
"Your new hex color is ##{color}"
end
Also, I didn't know about array.sample() but quite like it. I'm going to have to implement it in languages I use. rand, in the languages I know, would involve aligning output to array size, casting as integer and making the index, so using sample is the clear choice, once you know it exists.
But I agree on note taking and "whatever works for you". Thank you for writing this.
You make a good point about separating the why and how with the comments and code. Your example is a lot cleaner and seems like it would be appropriate for more complex applications.
I've heard references to Getting Things Done (I go by the 2 minute rule when I can).
Thanks for sharing!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have several thoughts that don't have a coherent through-line, so I'll proceed and hope coherence comes.
One of the concepts in David Allen's Getting Things Done is using external memory. In fact, that's the only part that stuck, and I'm eternally grateful. I've found that taking notes by hand helps them "stick", which I credit to years of pre-computer education, but follows your NPR link.
Regarding code comments, I'm torn. Jeff Atwood suggests writing better code instead of comments, and I'm not 100% on board, I lean toward the "why" while leaving the "how" to code. I might do something more like this:
Also, I didn't know about
array.sample()
but quite like it. I'm going to have to implement it in languages I use.rand
, in the languages I know, would involve aligning output to array size, casting as integer and making the index, so usingsample
is the clear choice, once you know it exists.But I agree on note taking and "whatever works for you". Thank you for writing this.
You make a good point about separating the why and how with the comments and code. Your example is a lot cleaner and seems like it would be appropriate for more complex applications.
I've heard references to Getting Things Done (I go by the 2 minute rule when I can).
Thanks for sharing!