13

Is it possible to write code that my future self can understand?

Comments
  • 5
  • 2
    All the time
  • 3
    Yes, comment like Morgan Freeman
  • 2
    Short answer: No.
    Long answer: No.
  • 0
    Use descriptive names and comment even what you currently think is obvious.
  • 1
    Yes, there is a way:

    1. Name your variables and functions in a way that explains what they do.

    2. Abstract things by plitting your code into a a LOT of functions (you want around 5-15 lines of code per function) (you can call a previous functions in your new functions)

    3. Add comments where you've done something that isn't quite obvious when you see it at first sight.
  • 1
    Understanding code is harder than writing it. If you write as clever as you can, you will be too stupid to understand it later.

    Code expresses what it does and how. Comments express what it is supposed to do and why.

    When i comment, i think about how i would explain that part to someone else who does not know what i know, which is probably future-me.
  • 0
    Only I you are at the same state of mind every time you see the code.

    Or if your comment skills are top.
  • 0
    That's why you write tests for your code
Add Comment