• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Code Optimization

 
Greenhorn
Posts: 12
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

 
Marshal
Posts: 79151
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79151
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    Ranch Hand
    Posts: 679
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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

  •  
    Bartender
    Posts: 10780
    71
    Hibernate Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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 Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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 Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks to all!
     
    Campbell Ritchie
    Marshal
    Posts: 79151
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Sandeep Gabhale wrote:Thanks!

    [On behalf of everybody who posted] “You’re welcome”
    reply
      Bookmark Topic Watch Topic
    • New Topic