Java Best Practices

When creating a Java application, the following best practices should be considered:

  • Program to an interface, not an implementation.
  • A class should have only one reason to change.
  • Identify the code that vary and separate it from the code that remains the same.
  • No principle is a law. Principles just provide guidance. Hence should be used when and where they are helpful.
  • All designs have tradeoffs like abstraction vs speed, time vs space. Hence, all factors should be taken into account before applying them.
  • Favor composition over inheritance.
  • Classes should be open for extension but closed for modification.
  • Depend on abstraction. Do not depend on concretion.
  • Only talk to your friend.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s