hts.StevenWood.com

Good Programming Practices

Home ] Up ] How to use Methods in Java ] Methods and Parameters in Java ] Creating User-Defined Methods ] Common Programming Errors ] [ Good Programming Practices ] Lab Exercises ] Labs 1 ] Labs 2 ] Rubric ][ Last Page ]

Good Programming Practices

  1. Familiarize yourself with the rich collection of classes and methods in the Java API and with the rich collections of classes available in various class libraries.
  2. Place a blank line between method definitions to separate the methods and enhance program readability.
  3. Although it is not incorrect to do so, do not use the same names for the arguments passed to a method and the corresponding parameters in the method definition. This helps avoid ambiguity.
  4. Choosing meaningful method names and meaningful parameter names makes programmes more readable and helps avoid excessive use of comments.
  5. Use only uppercase letters (with underscores (_) between words) in the names of final variables. This makes these constants stand out in a program.
  6. Using meaningfully named final variables rather than integer constants (such as 2) makes programmes more readable.
  7. Avoid local variable names that hid instance variable names. This can be accomplished by avoiding the use of duplicate identifiers in a class.
  8. Overloading methods that perform closely related tasks can make programmes more readable and understandable.

 

 

Source: Deitel, H.M. and Deitel P.J. Java: How to Program. 3rd ed. Upper Saddle River, New Jersey. Prentice Hall.1999. ISBN 0-13-012507-5, p 253. 

Home ] Up ] How to use Methods in Java ] Methods and Parameters in Java ] Creating User-Defined Methods ] Common Programming Errors ] [ Good Programming Practices ] Lab Exercises ] Labs 1 ] Labs 2 ] Rubric ][Last Page]
All material on this site is copyright © 1997- by Steven Wood or as credited. All right reserved. Use of this site indicates you agreement with the  terms of use.
Send comments or questions to about this page.
Every attempt has been made to credit work under copyright. If there are any claims that copyright has been missed please contact the .
+SDG+