Well, whether you are using comments to "separate code" or not, they should be included, always. Especially if someone else will have to maintain the code down the road. If it's just you and always will be then it's up to you of course. But if you are anything like me, I'm likely to forget what or why I was doing something a couple of days after I do it so comments help.
Let's say you have a comment that says "# Calculate age of data entry (in minutes)" and then a code block that proceeds to do that. Instead you can extract that code block into its own method called "def calculate_age_of_data_entry_in_minutes(data)". Not only does that make the original code block more readable by making it shorter, it also allows the 'calculate_age_of_data_entry_in_minutes' block to be called by other methods in the future, just in case they need to calculate the age of data entries as well.
#sbi-skip
Well, whether you are using comments to "separate code" or not, they should be included, always. Especially if someone else will have to maintain the code down the road. If it's just you and always will be then it's up to you of course. But if you are anything like me, I'm likely to forget what or why I was doing something a couple of days after I do it so comments help.
Oh yes yes.
What do you write codes about?
You can change the comment text into a method name of the same text. That way, it is even reusable!
Hmm, I don't understand that.
Can you explain a little more?
Posted via D.Buzz
Let's say you have a comment that says "# Calculate age of data entry (in minutes)" and then a code block that proceeds to do that. Instead you can extract that code block into its own method called "def calculate_age_of_data_entry_in_minutes(data)". Not only does that make the original code block more readable by making it shorter, it also allows the 'calculate_age_of_data_entry_in_minutes' block to be called by other methods in the future, just in case they need to calculate the age of data entries as well.
#sbi-skip
Ah, I understand very well now. Thank you very much for this long explanation. 😀