Search code examples
formattingcoding-stylechildren

How to explain to a high school hacker that indenting and verbose variable names are good things?


He is good programmer (won some competitions) but he absolutely ignores formatting. He consider i, j, k beautiful... I hope he won't find out about existence of goto keyword.


Solution

  • I told my students (post-secondary) that they had the choice of writing code well or of me writing their assignments in the same sort of way that they wrote their code. I told them I would write the following program:

    • take the text of the assignment
    • lookup a number of the words in a thesaurus and replace them with obscure versions
    • remove all punctuation
    • remove all whitespace
    • convert everything to lower case
    • insert random whitespace
    • capitalize random letters

    They could then have the assignment... hey its "right" (all of the words are there) good luck understanding what the assignment is though.

    Oddly the complaints stopped at that point :-)

    I also compared it to English. We use paragraph breaks, capitalizations, etc... as a convention. When someone chooses not to follow the conventions it makes reading much harder.