2004-3-21 Sunday (Sunday)
Java Program Coding Specification Programming Skills Swing Debugging If this class can be cloned, then the next step is Clone method: Counterset); obj.packets = (int []) packets.clone (); obj.size = size; tp NEW INTERNALROR ("Unexpected ClonyNotsupportedException:" E.GetMessage ());} Tostring () {String Retval = "Counterset:"; for (int i = 0; i Initialization The code is a very useful template: Class Colour {Public Static Final Colour Black = New Colour (0, 0, 0); Public Static Final Color Red = New Colour (0xFF, 0, 0 ); Public static final color green = new color final colour blue = new color final color blue = new color final color White = New Color (0xff) 0xFF, 0xFF);} This technique implements constants that can be used like the types of RED, GREEN, and Blue can be used like other languages. They can compare with '==' operators. But this is used in this way: if a user uses this way to create a color Black There will be an error. Her equal () method is still valid. For this reason, the defect of this technology is best to indicate in the document, or only in your own package. Swing In fact, try not to mix them up. Scrolling AWT components award assembly is definitely not to use JScrollpane classes to implement scrolling. When scrolling the AWT component, you must use the AWT SCROLLPANE component to be implemented. Avoid using AWT components in the InternalFrame component try not to do this, otherwise there will be unpredictable consequences. Be careful when using the POP-UP menu containing the AWT component, try not to use it like this. Debugging debugging is a very important part of software development, there is a part of the software lifecycle. Debug can be opened with configuration, the key is the most basic. A very commonly used debugging method is to use a PrintStream class member. When you do not define the trial flow, you will define a debug method to set the stream of debugging. In the case of writing code, performance issues should be considered from head to tails. This is not to say that time should be wasted on the optimization code, but we always remind yourself to pay attention to the efficiency of the code. For example, if there is no time to implement an efficient algorithm, then we should record in the document so that you will come again in the future. Not all people agree to optimize performance this view when writing code, they think that performance optimization should be considered in the later stage of the project, that is, after the outline of the program has been implemented. Unnecessary object structure Do not construct and release objects in the loop Use StringBuffer objects to use StringBuffer classes when processing string, and the StringBuffer class is the basis for constituting the String class. The String class encapsulates the StringBuffer class, (at the expense of more time) provides a secure interface to developers.