Thanks and Regards,<br />Jagadish
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Thanks and Regards,<br />Jagadish
For my latest books on Java, including Introducing JavaFX 8 Programming, see HerbSchildt.com
Do not wait to strike till the iron is hot; but make it hot by striking....
Manoj Kumar Jain wrote:static instance variable
Manoj Kumar Jain wrote:I need only one instance of the class so not creating object, just using static instance variables.
Manoj Kumar Jain wrote:
does using most of the variables in application as static make the application slow ?
John Jai wrote:
Manoj Kumar Jain wrote:I need only one instance of the class so not creating object, just using static instance variables.
Are you referring to singleton - sorry the statement is not clear. When you don't create any object, then there is no instance of the class. Please DontWakeTheZombies
Do not wait to strike till the iron is hot; but make it hot by striking....
Manoj Kumar Jain wrote:we are also having methods most of them are static.
Manoj Kumar Jain wrote:so wondering if this is impacting its performance, is this some architecture problem
Joanne
Jeff Verdegan wrote:
Do you understand what "static" means in terms of the Java language and how that relates to our design?
Do not wait to strike till the iron is hot; but make it hot by striking....
Joanne
Manoj Kumar Jain wrote:
Jeff Verdegan wrote:
Do you understand what "static" means in terms of the Java language and how that relates to our design?
Yeah static means that this variable is related to class and not specific to any instance of the class.
So this can be used with/without creating the object of the class
But while googling for the same problem on many blogs/forums it was mentioned that static cause memory issue,
Do not wait to strike till the iron is hot; but make it hot by striking....
Jeff Verdegan wrote:
While that's technically true, I don't like to look at it that way. It makes it sound like creating an instance is a bad thing, and using statics "lets" you avoid it. That's the wrong view to take when working in an OO paradigm.
But while googling for the same problem on many blogs/forums it was mentioned that static cause memory issue,
As stated, that's utter nonsense. If you can provide the exact citation, we can help you under stand what was really meant, or if the author was just off his rocker.
Do not wait to strike till the iron is hot; but make it hot by striking....
Manoj Kumar Jain wrote:
however one of the link i followed was as below:
http://gbracha.blogspot.com/2008/02/cutting-out-static.html
Manoj Kumar Jain wrote:Yes Joanne, your first StaticClass is exactly that, what we are doing, we are loading all the data in static variables (lots of data from file/database) that might be required in the application further. This is a Swing desktop application having around 10-15 screens and lots of functionality. so as soon as GUI is up we are having all data in memory irrespective of that whether it is being used or not.
I am getting a point now that actually using static variable is not the root cause of the problem, the reason is that we are keeping all the data in memory whether we required it now or not, and probably we are doing this because we don't required many instances of class and just using the class to solve our purpose and ignoring to create a instance.
Joanne
Joanne
Joanne Neal wrote:
JagadishManoj - you might also want to read this.
It's always best to tell us what your actual problem is, rather than asking questions about something you think might be a possible solution. It would have saved everyone a lot of time.
Edit - I don't suppose Jagadish is all that interested now.
Do not wait to strike till the iron is hot; but make it hot by striking....
I promise I will be the best, most loyal friend ever! All for this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|