How to Create Effective Comments: Mastering the Art of Code

A blog post about comments? Really?

I am writing this blog for posterity. All I want is to help other people who, like myself might be on the journey to become a master at the art of coding.

It would seem that being great at coding is creating habits which give back in the far future and slowing down software rot at individual level.

With that in mind, we will take the most neglected part of coding and bring it to forefront: Commenting.

There have been multiple blogs written about comments, yet personal records are sparse and difficult to find.

One thing is for certain and everyone has a clear consensus on this, you don't need to comment all of your code, only those parts which could be re-used in the future by another developer.

My findings on Comments for methods.

Getting to comments, what could be the fields that would help a future developer use your methods?

Lets see, going through stackoverflow and wide array(hehe) of blogs, I have narrowed it down to 5 items:

  1. Description of what the methods does and if there are some special instructions for the developer before using it.
  2. Author. I think putting an author name for a method gives a sense of accountability and pride for your work, which might lead to the author creating a clean and beautiful code(more on that in later posts).
  3. Modified date: The last modified date for any method to make it clear what and the last change was.
  4. Exceptions, errors: This might serve as a warning to the next developer as to what might lead to a breakdown of the code. Going through this yourself for your own methods might even lead to finding errors you didn't know you had.
  5. Return: a clear sentence that says what the developer might expect in return complete with data structure and the data expectation.
*A brief description of the method
*@author name-of-author
*@since date of creation
*@throws Exception or error that could be expected
*@Return List of all Objects that will be returnable

Inline comments.

"I did it this way because nothing else works. Why don't you try another implementation?"

Now that we have thought of the best way to write comments for methods, we sometimes just need to create inline comments just to explain some piece of code in the best way possible.
So what do we add in inline comments?

I follow a clear method to keep these comments to a minimum(Nobody likes to read too much anyway),
Only leave inline comments for other programmers who:
  • Might get stuck
  • Might take a while to understand your code
  • Might need an explanation of why certain implementation is the best possible thing for now.
Also, add TODOs to let other programmers know that a certain method can be improved in the future with another implementation.

In the end, its a kind of an Art

At the end of the day, you could totally ignore all this and still write great code. Yet, to be a master, you need to be improving at every part of it. So why not start with something that takes no technical expertise? In essence, to reach a Goal, small habits take you most of the way.


  1. Casino - Web Services -
    Visit - the 김제 출장샵 best Casino. Web 남원 출장마사지 Services with 양산 출장마사지 the most detailed website security, instant casino 밀양 출장안마 login, game support, 구리 출장마사지

  2. Some regions are highly restrictive in terms of|in relation to} playing advertising. We’ll take a more in-depth} take a look at|have a glance at} well-liked and effective advertising methods in a while on this article. The degree of regulation shall be the first thing you should to} contemplate. You may also take a look at|have a glance at} regulations when choosing the jurisdiction for acquiring a playing license. Some playing authorities forbid their licensees from concentrating on certain geographical areas, so you’ll have to verify your gaming license allows you to face your desired goal market. But as working a casino 바카라사이트 isn't a recreation of probability, but skill, you’ve received to offer your all to keep up with the competitors.


Post a Comment

Popular Posts