• 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

How to make my code more fast, secure and robust ?

 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recently I have started putting emphasis on making my applications run faster as well as take advantage of all the cores in the CPU , but this is new area of learning for me , can any experience guy who has gone through this help me to accomplish this ?
alL I want to learn is
1. How can I make sure that my programe will take utilization of all the cores in any CPU ?(I Guess just creating multiple Threads will not solve this problem ?)
2. How can I make sure that my programe will take minimum memory ?
3. And finally how to write a robust more secure code ? (which is tough for other peoples to break)

any books, suggestions, articles on the net is most welcome
thanks..........
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

naved momin wrote:1. How can I make sure that my programe will take utilization of all the cores in any CPU ?(I Guess just creating multiple Threads will not solve this problem ?)


Find places in your program that can be parallelized, and you can submit them as tasks in an executor service. However, this is usually only useful for responsiveness of the program, and not necessarily for absolute speed, since there is an overhead in using multiple threads. Save this for big tasks, such as handling requests or transactions from remote clients, and not for nano-optimizations such as performing a merge-sort concurrently.

2. How can I make sure that my programe will take minimum memory ?


Just program neatly and in a simple manner, and memory usually takes care of itself. If you jump through silly hoops to increase performance (either memory use or speed), you usually end up hurting performance instead. Make sure that variables you don't use anymore go out of scope, and you don't accidentally save them somewhere. Breaking up big methods in smaller ones that do simple things helps with this.

3. And finally how to write a robust more secure code ? (which is tough for other peoples to break)


Write simple methods with a clear contract, enforce the requirements in the method (by throwing exceptions when necessary) and program defensively. You should read Jushua Bloch's Effective Java to learn a lot about writing good clean code.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

thanks stephan
 
Can't .... do .... plaid .... So I did this tiny ad instead:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic