[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: programing styles
I would say the first one is - keep variable
declarations as local as possible - better
for garbage collection also, in most cases.
In your case, you gain nothing by declaring
them outside the for loop as you don't seem
to be using them outside the loop.
Cheers,
Magesh
**************************************************
* The surest sign that intelligent life exists *
* elsewhere in the universe is the fact that it *
* has never tried to contact us. *
**************************************************
----- Original Message -----
From: "Gudavalli, Manidhar" <manidhar.gudavalli@eds.com>
To: <ajug-members@ajug.org>
Sent: Friday, November 01, 2002 2:34 PM
Subject: programing styles
>
>
>
> HI
>
> Which style of coding is best ?
>
> [1]
> private void myproc(Vector vect){
> for (i=1; i < vect.size() ; i++){
>
> MyObject obj = (MyObject) vect.elementAt(i);
> int y = obj.getY();
> }
> }
>
> or
> [2]
> private void myproc(Vector vect){
> MyObject obj = null;
> int y= 0;
>
> for (i=1; i < vect.size() ; i++){
>
> obj = (MyObject) vect.elementAt(i);
> y = obj.getY();
> }
> }
>