# Proper variable names!

• (2 Pages)
• 1
• 2

## 18 Replies - 6501 Views - Last Post: 26 February 2013 - 02:20 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=266959&amp;s=346d11b685e2c5f07b122598002c0b29&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 andrei31

• New D.I.C Head

Reputation: 14
• Posts: 1
• Joined: 14-January 10

# Proper variable names!

Posted 16 February 2012 - 02:07 PM

POPULAR

This is a function for printing a heap stored like a vector. I
forgot his exact idea. This code was sent to a course signup .

I find it hard to read, thanks to those very suggestive vars. Do you?

```void my_print(int a[], int x,int t) {
int i,s,l,j,k,b;
s=2;l=0;
for(i=1;i<t;i++) {s=s*2 +4;
l=l*2+3;}
for(j=1;j<=s;j++) printf("*");
printf("\n");

k=1;b=1;
for(i=1;i<=x;i++) {
if (b==1) { b=0;
for(j=1;j<=l;j++) printf(" ");}
printf("%4d",a[i]);
if (i!=1)
for(j=1;j<=s;j++) printf(" ");
if((i+1)==(pow(2,k))) {printf("\n");b=1;s=(s-4)/2;l=(l-3)/2;k++;}

}
printf("\n");

}

```

Is This A Good Question/Topic? 14

## Replies To: Proper variable names!

### #2 kolotyluk

• New D.I.C Head

Reputation: 13
• Posts: 5
• Joined: 14-January 11

## Re: Proper variable names!

Posted 16 February 2012 - 05:52 PM

POPULAR

I am laughing so hard that it hurts, or is it I hurt so hard that I am laughing...

I recently had to deal with the same piece of Java code where the variable 'identifier' was abused three times

```IdentifierPeer identifier = new IdentifierPeer();

Identifier identifier = new Identifier();

String identifier = new Identifier().getIdentifier();

```

It takes a special kind of mental retardation to dream up shit like that.

It reminds me of when I was in high school, there were three brothers all named after their father "Guy Louie" and no middle names to distinguish them. I was in a class once where two of the brothers were in the same class - it drove the teacher nuts.

### #3 November-06

• D.I.C Regular

Reputation: 45
• Posts: 348
• Joined: 04-January 11

## Re: Proper variable names!

Posted 21 February 2012 - 08:28 PM

POPULAR

Wow! There's a lot of identifiers that I can't identify which identifier I really need to identify.

### #4 kolotyluk

• New D.I.C Head

Reputation: 13
• Posts: 5
• Joined: 14-January 11

## Re: Proper variable names!

Posted 21 February 2012 - 08:45 PM

LOL

### #5 Byrdsong

Reputation: 6
• Posts: 194
• Joined: 16-November 08

## Re: Proper variable names!

Posted 23 February 2012 - 11:47 AM

HaHa!! Awesome, best nightmare yet!!

### #6 baavgai

• Dreaming Coder

Reputation: 4882
• Posts: 11,278
• Joined: 16-October 07

## Re: Proper variable names!

Posted 23 February 2012 - 12:16 PM

POPULAR

That's excellent. It's like an alphabet puked on my screen with curly braces.

### #7 v0rtex

• Caffeine: db "Never Enough!"

Reputation: 218
• Posts: 758
• Joined: 02-June 10

## Re: Proper variable names!

Posted 23 February 2012 - 12:21 PM

Wow I would have shot myself rather than read that code O.o

### #8 Yatta!

Reputation: 16
• Posts: 116
• Joined: 06-September 09

## Re: Proper variable names!

Posted 23 February 2012 - 03:26 PM

Solution?

KILL IT WITH FIRE

• New D.I.C Head

Reputation: 1
• Posts: 9
• Joined: 20-January 12

## Re: Proper variable names!

Posted 26 February 2012 - 09:35 AM

Hahaha reminds of a post I randomly stumbled on yesterday http://computegeeken...-hack-in-c.html

### #10 cap0

• New D.I.C Head

Reputation: 5
• Posts: 32
• Joined: 11-December 11

## Re: Proper variable names!

Posted 27 February 2012 - 11:39 AM

It's like trying to code in mandarin?

WHAT IS THIS DARK MAGIC?

### #11 fastlane85

• New D.I.C Head

Reputation: 9
• Posts: 17
• Joined: 13-March 10

## Re: Proper variable names!

Posted 29 February 2012 - 09:38 AM

Yatta!, on 23 February 2012 - 03:26 PM, said:

Solution?

KILL IT WITH FIRE

Agreed, fire is the only remedy.

### #12 blackcompe

• D.I.C Lover

Reputation: 1009
• Posts: 2,186
• Joined: 05-May 05

## Re: Proper variable names!

Posted 29 February 2012 - 09:42 AM

Quote

String identifier = new Identifier().getIdentifier();

That's just ridiculous.

### #13 Redwizard000

• New D.I.C Head

Reputation: 0
• Posts: 2
• Joined: 29-February 12

## Re: Proper variable names!

Posted 29 February 2012 - 08:15 PM

I want to smack this person upside the head with a copy of C++ for dummies duct taped to a baseball bat.

### #14 Theomi

Reputation: 9
• Posts: 84
• Joined: 17-January 10

## Re: Proper variable names!

Posted 03 March 2012 - 05:00 PM

Reminds me of the code we got from our teacher for a project needing a Floyds algorithm.
We used 2 weeks debugging the program because it would not work and finally found out that a k was misplaced

```	public double[,] Floyd()
{
// initializing
FloydPath = new int[GetNodeCount(), GetNodeCount()];
double[,] m = new double[GetNodeCount(), GetNodeCount()];

for (int i = 0; i < GetNodeCount(); i++)
for (int j = 0; j < GetNodeCount(); j++)
{
m[i, j] = GetWeight(i, j);
FloydPath[i, j] = -1;
}

// floyds algorithm
for (int k = 0; k < GetNodeCount(); k++)
{
for (int i = 0; i < GetNodeCount(); i++)
{
for (int j = 0; j < GetNodeCount(); j++)
{
if (m[i, k] + m[k, j] < m[i, j])
{
m[i, j] = m[i, k] + m[k, j];
FloydPath[i, j] = k;
}
}
}
}
return m;
}
```

### #15 idkau

• New D.I.C Head

Reputation: 1
• Posts: 5
• Joined: 06-June 12

## Re: Proper variable names!

Posted 24 June 2012 - 10:29 PM

that hurt my brain lol