Small Java Programming Quick Tips

  1. Build Java class starting from the default scope before making way up to the protected scope and then the public scope.
  2. Use small short-lived immutable objects as opposed to large objects as much as possible.
  3. Restrict the use of getters/setters and if one is provided, ensure the attribute get/set is immutable and not modifiable via reference (eg. elements in a collection).
  4. Methods should return either a value or an exception. Returning a null object is not recommended and should be limited to checking that a variable has been removed/cleared/nullified.
This entry was posted in Program Coding and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.