-
Book Overview & Buying
-
Table Of Contents
Android Programming for Beginners - Fourth Edition
By :
Code comments are like time-capsule messages that we leave for ourselves in our code to remind ourselves why we wrote it. If you work on a team, the messages are also for your colleagues. Why we need to do this isn't always obvious to new programmers, so let's explore.
Android code can grow in scale very quickly. Unless you have a rare mental gift, even the best programmers will not remember why they wrote a certain piece of code when they revisit it after some time.
There is an old programming saying that programmers spend more time reading and understanding old code than they do writing new code.
There is an old programming joke that goes something like this. "What idiot wrote this code?" Some time passes... "Oh, it was me".
Code comments help solve these problems by providing clear explanations for why certain lines of code exist. For example, here is a Kotlin single-line comment.
// This code is never executed – it is just...