M
mmm.guitar
Hello,
I have a slighly odd question regarding coding style and program
efficiency which I would appreciate a short answer to.
Taking these two code examples to call a method and send a String from
an object and String made up on the spot:
Example A:
myMethod( myObject.getString(), "This is some text" );
Example B:
String my_string;
String my_text;
my_string = myObject.getString();
my_text = "This is some text";
myMethod (my_string , my_text);
Which one would more efficient to run and which would be seen as a
'better' coding style.
My thoughts - running effiency would the same, because the compiler I
think will compile everything down (i.e. great difference between
compiled code and written code) but I'm not sure about the specifics of
compiling, so given that Example B will take more time to compile. I
think example B is easier to understand as well and thus the better
coding style? - also considering a method may have say 10 inputs.
Or a compromise?
String my_string;
my_string = myObject.getString();
myMethod (my_string , "This is some text");
Thanks for any help, I am just trying to find a descent coding style.
I have a slighly odd question regarding coding style and program
efficiency which I would appreciate a short answer to.
Taking these two code examples to call a method and send a String from
an object and String made up on the spot:
Example A:
myMethod( myObject.getString(), "This is some text" );
Example B:
String my_string;
String my_text;
my_string = myObject.getString();
my_text = "This is some text";
myMethod (my_string , my_text);
Which one would more efficient to run and which would be seen as a
'better' coding style.
My thoughts - running effiency would the same, because the compiler I
think will compile everything down (i.e. great difference between
compiled code and written code) but I'm not sure about the specifics of
compiling, so given that Example B will take more time to compile. I
think example B is easier to understand as well and thus the better
coding style? - also considering a method may have say 10 inputs.
Or a compromise?
String my_string;
my_string = myObject.getString();
myMethod (my_string , "This is some text");
Thanks for any help, I am just trying to find a descent coding style.