• Post Reply Bookmark Topic Watch Topic
  • New Topic

new keyword + performance issue  RSS feed

 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,

I am using factory Design pattern and I have got code where I have plethora of records ( rows in database) .
For each row i have to validate the records after fetching the whole list from database.


- For every row validation uses a Class object

each time a row is validation a new object is generated like.



So for thousands of records it is generating objects and assigning it to brsValidation.
Does it create performance problem?
please clear me with it as i want to code efficiently.

Thanks in advance
Raza!


 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating small objects in Java is very inexpensive, especially in the most recent JVMs, because Java's garbage collector is optimized for small, short-lived objects. It's unlikely in this case that creating this object has any real impact on your application's performance.

you should always, always code first for clarity and readability; later, if you find there is a performance problem, you can make your code more complicated, if necessary, to create fewer objects.
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ernest!
For your valuable information.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!