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
Nice post! Extracting methods is so important for readability. You might like the Software Engineering community where we are trying to create a place for professional IT workers to ask for or give advice about tech-related skills and careers.
Thanks but too lazy for full posts. I stay on micro-blogging fine for my time windows. I also love #python and try to post to the Python group. But good luck!!
Hmm, I still prefer comment lines. 😀
Posted via D.Buzz
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. 😀
Nice post! Extracting methods is so important for readability. You might like the Software Engineering community where we are trying to create a place for professional IT workers to ask for or give advice about tech-related skills and careers.
https://hive.blog/trending/hive-186568
#sbi-skip
Thanks but too lazy for full posts. I stay on micro-blogging fine for my time windows. I also love #python and try to post to the Python group. But good luck!!