#125826 - keldon - Tue Apr 17, 2007 11:01 am
This is not c/c++ specific so I put it here. Which do you think is better, and why.
(1)
(2)
(3)
I quite like the third one because you can keep the variable local to the function while also providing a descriptive name of the variable being sent; but you cannot do this in any language (I know). The next one for me is the first one, and you can use some form of notation to separate these variables from others.
EDIT: in fact for the third one (if it were to be a new feature to a language/script language) you could have a different keyword altogether such as *hmm* param!
(1)
Code: |
int width;
int height; boolean hasZBuffer; Bitmap bitmap = new Bitmap ( width = 80, height = 60, hasZBuffer = true ); |
(2)
Code: |
final (or const) int width = 80;
final (or const) int height = 60; final (or const) boolean hasZBuffer = false; Bitmap bitmap = new Bitmap ( width, height , hasZBuffer ); |
(3)
Code: |
Bitmap bitmap = new Bitmap ( int width = 80, int height = 60, boolean hasZBuffer = true ); |
I quite like the third one because you can keep the variable local to the function while also providing a descriptive name of the variable being sent; but you cannot do this in any language (I know). The next one for me is the first one, and you can use some form of notation to separate these variables from others.
EDIT: in fact for the third one (if it were to be a new feature to a language/script language) you could have a different keyword altogether such as *hmm* param!