• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Code Optimization  RSS feed

 
Sandeep Gabhale
Greenhorn
Posts: 12
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Does anyone help me out with code optimization tips and suggestions.

I searched on Google... but couldn't got good examples/tips.

Its would be great, if someone have done code optimization in his/her project then please share it!

 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hints
  • 1: Don’t do it.
  • 2: Optimisation is a bad idea
  • 3: You can introduce bugs or even worsen performance
  • 4: There is some really useful stuff in this interview with Brian Goetz
  •  
    Campbell Ritchie
    Marshal
    Posts: 56546
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The one thing you always ought to do is to ensure you are using appropriate algorithms. Look at the comments about Collections#sort(java.util.List) for an example.
     
    Stuart A. Burkett
    Ranch Hand
    Posts: 679
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Campbell Ritchie wrote:Hints
  • 1: Don’t do it.
  • 2: Optimisation is a bad idea
  • 3: You can introduce bugs or even worsen performance
  • 4: There is some really useful stuff in this interview with Brian Goetz

  • I would clarify this with
  • 1: Don’t do it unless you have seen a performance problem and have sucessfully identified what is causing the problem.
  • 2: Optimisation is a bad idea unless you have seen a performance problem and have sucessfully identified what is causing the problem
  • 3: You can introduce bugs or even worsen performance so if you have seen a performance problem and have sucessfully identified what is causing the problem, make sure you have sufficient tests and benchmarks in place before making any changes, so that you reduce the chances of introducing bugs and will know if your optimisation has worked

  •  
    Winston Gutkowski
    Bartender
    Posts: 10575
    66
    Eclipse IDE Hibernate Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Sandeep Gabhale wrote:Does anyone help me out with code optimization tips and suggestions.

    I like Michael A. Jackson's advice; and it applies to all optimization, not just in Java:
    1. (as Campbell said) Don't do it.
    2. (for experts only) Don't do it yet.

    You might also heed the words of Wulf below.

    Winston
     
    Sandeep Gabhale
    Greenhorn
    Posts: 12
    Android Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Campbell Ritchie wrote:Hints
  • 1: Don’t do it.
  • 2: Optimisation is a bad idea
  • 3: You can introduce bugs or even worsen performance
  • 4: There is some really useful stuff in this interview with Brian Goetz


  • Hi Campbell,

    Thanks for your valuable suggestions.

    I read the article of Mr. Brian Goetz.
    From the article, I understood that write simple code using basic OOPs Concept.
    Also, got some exposure to new features of JDK 6.
     
    Sandeep Gabhale
    Greenhorn
    Posts: 12
    Android Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks to all!
     
    Campbell Ritchie
    Marshal
    Posts: 56546
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Sandeep Gabhale wrote:Thanks!
    [On behalf of everybody who posted] “You’re welcome”
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!