Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Appropriate variable names?  RSS feed

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Above is my code.....Suggest me appropriate variable names for i,j,k?
 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Ranch,

Always use code tags for your code. That makes it much easier to go through it. I don't think anyone would bear the pain of going through your code until you useCodeTags. So, do it first

Vishal
 
Bartender
Posts: 3320
86
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Suggest me appropriate variable names for i,j,k?


The name you give to a variable should accurately describe its purpose eg if it holds the number of guests in a hotel use something numGuests or guestCount etc.
Many years ago someone far wiser than me told me if you can't think of a good descriptive name for your class, method or variable then stop coding immediately because you clearly don't fully understand the problem.
So basically what I'm saying is you should already know what these variables should be called, so what do they do?
 
Tony Docherty
Bartender
Posts: 3320
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code. I've added them for you this time.
 
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony has given you a good advice about variable names. For what you asked, i, j, k are usually used as loop counters.

You seem to try to write clean code, so I would recommend you also be consistent with code formatting. Choose one style for your code, and try not to change it throughout the code.
 
Amruta Jegarkal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
j is a variable name used in loop so it doesn't matter for it.But k is holding a return value so what name i must give to that and even i is an array which holds return value of executeBacth()?So what kind of name i must use.
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Amruta Jegarkal wrote:j is a variable name used in loop so it doesn't matter for it.But k is holding a return value so what name i must give to that and even i is an array which holds return value of executeBacth()?So what kind of name i must use.


As Tony said, use a name that describes its use (or contents). In the case of executeBatch(), it returns an update count, so why not call it:
int updateCounts[] = preparedStatement.executeBatch();
or indeed
int batchResults[] = preparedStatement.executeBatch();
?


Winston
 
Amruta Jegarkal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!