Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
General Method Best Practices               Parag Shah     http://www.diycomputerscience.com
Follow Java coding conventions
The method name should be clear
Avoid using names of datatypes in methods         Eg: getAccountsArrayList()
Names should be consistent Eg: Either delete() or remove()
Do not go overboard in providing convenience                 methods
Avoid long parameter lists
For parameter types, favor interfaces over classes
Use overloading judiciously
Do not invoke non final public or protected methods from           the constructor of a non final class
Avoid returning null as far as possible.  Throw Exception to signify a problem   Return an empty list instead of null
A little something before leaving     5 == x instead of x == 5       “someStr”.equals(x)           instead of       x.equa...
General method best_practices
General method best_practices
General method best_practices
General method best_practices
Prochain SlideShare
Chargement dans…5
×

General method best_practices

612 vues

Publié le

This presentation discusses some general best practices which programmers should keep in mind when creating methods in Java.

Publié dans : Technologie, Santé & Médecine
  • Identifiez-vous pour voir les commentaires

  • Soyez le premier à aimer ceci

General method best_practices

  1. 1. General Method Best Practices Parag Shah http://www.diycomputerscience.com
  2. 2. Follow Java coding conventions
  3. 3. The method name should be clear
  4. 4. Avoid using names of datatypes in methods Eg: getAccountsArrayList()
  5. 5. Names should be consistent Eg: Either delete() or remove()
  6. 6. Do not go overboard in providing convenience methods
  7. 7. Avoid long parameter lists
  8. 8. For parameter types, favor interfaces over classes
  9. 9. Use overloading judiciously
  10. 10. Do not invoke non final public or protected methods from the constructor of a non final class
  11. 11. Avoid returning null as far as possible. Throw Exception to signify a problem Return an empty list instead of null
  12. 12. A little something before leaving 5 == x instead of x == 5 “someStr”.equals(x) instead of x.equals(“someStr”)

×