Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

naming static int variables

I have quite a number of integer variables (most of them static, some non-static) in my code. Since am working on ajax testing, getting rid of these variables is not possible. Currently I use "int" prefixed to a word that matches the context where the variable is used. But too much of that makes my code look odd. For eg. I need to press cancel button whose id gets incremented with each run. So am using a static variable and I named it

static int intCancel;

Is there any particular pattern in which the variables can be named so as to make the code more readable?

like image 998
aradhak Avatar asked Mar 29 '26 19:03

aradhak


1 Answers

A common misconception is that variable names must be short. Consider expanding them to state what they are. IDEs make completing variable names easy. So numberTimesCancelSelected might be an option.

Consider reading Clean Code for a better discussion of this topic.

like image 118
John B Avatar answered Apr 02 '26 02:04

John B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!