Comments in Java about//TODO
// TODO Auto-generated method stub
Is that we write the class or inherit the interface automatically generated hints, can be left or not, but can prompt the reader this code is automatically generated
Find the method body according to the following path
Select Edit or double-click the text area for editing, delete the default content
About the role of @override
It can be said that @Override is pseudo-code, can represent the method of overriding the parent class, delete can also, but we can be used as a hint.
Tip This method is owned by the parent class, and if you write a @Overrideon a method that the parent class does not have, the compiler will usually make an error.
If there is no previous @Override, and the method name is not in the parent class, the compiler will consider this method to be an added method in the subclass itself.
You can refer to the following code:
This is an interface public interface framework{void Framemain (); Used to set the main window void frameinitial (); Used to initialize the individual parts void frameaction (); Used to add event void framelocate () to individual parts; Used to locate the individual parts in the position of the window void Frameadd (); Used to add individual parts to the main window void Toexit (); For a method that frees the window resource}/*** @Author: PQ * @Data: August 24, 2018 */public class test implements framework{public Test () { Framemain (); Frameinitial (); Frameaction (); Framelocate (); Frameadd (); This.setvisible (TRUE); Display window} @Override public void Framemain () {//TODO auto-generated method stub} @Override public void Frameinitial () {//TODO auto-generated method stubs} @Override public void Frameac tion () {//Todo auto-generated method stub} @Override public void Framelocate () {//TODO auto-generated method stub} @Override public void Frameadd () {//TODO Auto-generated method stub} @Override public void Toexit () {//TODO auto-generated method stub }}
Comment Questions
"Don't comment on Bad code-write it again."
Nothing is as useful as putting good notes.
Nothing is more capable of messing up a module than a messy note.
Nothing is more damaging than stale annotations that provide error messages.
Comments do not beautify the bad code
One of the common motivations for writing annotations is the existence of bad code.
Use code to illustrate
Sometimes you just need to create a function that describes the same thing as the comment.
- Good comment
- Legal information
- Comments that provide information
- An explanation of the intention
Interpretation
Note It is useful to translate the meaning of some obscure parameter or return value into a readable form, but it is sufficient to make the parameter or return value itself clear enough.
Warning
Don ' t look at me code!!!
TODO comments
Sometimes you can use TODO comments to annotate what our function is going to do, usually to indicate what the programmer thinks should be done, but for some reason the work is not done yet.
Amplification
Can be used to amplify some seemingly irrational code.
Bad Comment
Often bad comments are a support or excuse for bad code, a correction to a wrong decision,
Summary: Most of the time meaningful naming is more friendly than annotations.
Comments in Java