Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comments at end of method best practice?

Tags:

comments

c#

I have some code which has comments after each method saying this for example:

// End of contructor DbFactoryDBConnection()

Should a comment like this be used to indicate the end of a method or not? It was something picked up from an earlier employment where it was common place.

like image 695
CSharpened Avatar asked Dec 27 '22 02:12

CSharpened


1 Answers

I feel such comments are after methods which body does not fit in a single screen. I believe this is a good sign for the refactoring and splitting out such long methods to shorten ones or even extracting new entities/services/helpers. This is like C# region, sometimes it is used to hide very long code blocks and this is a sign that you have some kind of a God Object anti-patter.

like image 90
sll Avatar answered Jan 13 '23 02:01

sll