Being the "old guy" on most projects, often I run into a piece of code written in the latest "clever" style. If I can't just read through it and explain to myself what it does, I see if I can get the person who wrote, or at least someone who thinks they can understand it, it to explain to me, in simple terms, exactly what it does.
I open a code editor, and write their explanation down, in code. Very simple code.
By the end, I understand what it does, they understand what it does, the version we've just written will usually serve as a drop-in replacement and, most importantly, they usually "get" why I write code that's so simple and not clever at all.
And, for major bonus points, when the bug is hidden in (dare I say "created by"?) the clever, it pops right out and gets solved in the course of the "simple" rewrite.
Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
Being the "old guy" on most projects, often I run into a piece of code written in the latest "clever" style. If I can't just read through it and explain to myself what it does, I see if I can get the person who wrote, or at least someone who thinks they can understand it, it to explain to me, in simple terms, exactly what it does.
I open a code editor, and write their explanation down, in code. Very simple code.
By the end, I understand what it does, they understand what it does, the version we've just written will usually serve as a drop-in replacement and, most importantly, they usually "get" why I write code that's so simple and not clever at all.
And, for major bonus points, when the bug is hidden in (dare I say "created by"?) the clever, it pops right out and gets solved in the course of the "simple" rewrite.
Totally agree!
If you have to break open up a function (or any code) to understand what it does, there is something wrong with the function.
Great method, i will try practice as soon as possible. Thanks