Ask HN: What has heavily influenced your coding style?
1–6 of 6 posts
Re: Ask HN: What has heavily influenced your coding style?
#2Re: Ask HN: What has heavily influenced your coding style?
#3Just the KISS principal. I'll take repetitiveness over obfuscation anyday.
Re: Ask HN: What has heavily influenced your coding style?
#4But it also needs to be readable/pronounceable: and it needs to be readable even on cruddy screens / bad printouts. No "i" and "j" for loop counters, for example: the compiler doesn't care how long you make your names, so I use things like "kt" or "ndx" (because typos happen, and fewer characters that still convey the same meaning is acceptable).
I also do my best to never write overly clever code. Shared another [HN](https://blogs.msdn.microsoft.com/oldnewthing/20170719-00/?p=...) [post](https://news.ycombinator.com/item?id=14810014) with a little commentary on G+ last night:
Sadly - or, perhaps, happily - I can remember when I used to do wonky crap like this.
Then I learned the axiom, "if you code as cleverly as you can, you are, by definition, not clever enough to debug it" (I think it's called Kernaghan's Lever - but I may be mistaken).
Write code you can explain to a 4th grader. Or your grandma. If you have to stop and think about how clever it is, you are going to end up cleavering yourself with your feigned cleverness.Re: Ask HN: What has heavily influenced your coding style?
#5The second thing that has really influenced my coding style for the better (making it clearer and easier to understand) is writing a medium-sized program using a strictly functional language like Erlang. This will force you to use global state less, to write functions in such a manner that the function itself includes all the information required to understand it, simply because global state cannot be used and everything on which the function operates must be passed into it explicitly via its parameters.
[1] Clean Code (Robert Martin) http://amzn.to/2uewcpB
[2] Refactoring (Martin Fowler) http://amzn.to/2vnD7vx