aspose file tools*
The moose likes Java in General and the fly likes Coding Standard - Time Cost Factor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Coding Standard - Time Cost Factor" Watch "Coding Standard - Time Cost Factor" New topic
Author

Coding Standard - Time Cost Factor

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026



In class "A" I had declared an instance variable i and in
methodOne I am declaring a local variable i and initializing it to
some value. I need that value in methodThree but I have to go through
methodTwo(even if I am not doing any processing with that variable) and
I am calling methodThree from methodTwo.

Is it a good coding practice to do like this (or) to declare
the variable i as an instance variable and use it in the program.
I heard when we go for a instance variable, each time the instance
variable is used in the program it adds overhead to the object and
results in time cost.


Someone please help me with this doubt.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by vishnu prakash:
[CODE]
[...]
I heard when we go for a instance variable, each time the instance
variable is used in the program it adds overhead to the object and
results in time cost.


From where???

--
:alex |.::the_mindstorm::.


blog - InfoQ.com
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
In 99.99% of all cases, the time cost (if any) will be irrelevant. You should decide on this based on other reasons than performance, for example flexibility and maintainability of the design.


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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Coding Standard - Time Cost Factor