Proper variable names!

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 8089 Views - Last Post: 26 February 2013 - 02:20 PM Rate Topic: -----

#1 andrei31  Icon User is offline

  • New D.I.C Head

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

Proper variable names!

Post icon  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? :dontgetit:

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  Icon User is offline

  • New D.I.C Head

Reputation: 13
  • View blog
  • 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.
Was This Post Helpful? 12
  • +
  • -

#3 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 391
  • 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.
Was This Post Helpful? 13
  • +
  • -

#4 kolotyluk  Icon User is offline

  • New D.I.C Head

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

Re: Proper variable names!

Posted 21 February 2012 - 08:45 PM

LOL
Was This Post Helpful? 1
  • +
  • -

#5 Byrdsong  Icon User is offline

  • D.I.C Head
  • member icon

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

Re: Proper variable names!

Posted 23 February 2012 - 11:47 AM

HaHa!! Awesome, best nightmare yet!!
Was This Post Helpful? 1
  • +
  • -

#6 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5780
  • View blog
  • Posts: 12,596
  • 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.
Was This Post Helpful? 7
  • +
  • -

#7 v0rtex  Icon User is offline

  • Caffeine: db "Never Enough!"
  • member icon

Reputation: 223
  • View blog
  • Posts: 773
  • 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 :D
Was This Post Helpful? 1
  • +
  • -

#8 Yatta!  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 122
  • Joined: 06-September 09

Re: Proper variable names!

Posted 23 February 2012 - 03:26 PM

Solution?

KILL IT WITH FIRE
Was This Post Helpful? 2
  • +
  • -

#9 papadoo1  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • 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
Was This Post Helpful? 1
  • +
  • -

#10 cap0  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • 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?
Was This Post Helpful? 0
  • +
  • -

#11 fastlane85  Icon User is offline

  • New D.I.C Head

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

Re: Proper variable names!

Posted 29 February 2012 - 09:38 AM

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

Solution?

KILL IT WITH FIRE


Agreed, fire is the only remedy.
Was This Post Helpful? 0
  • +
  • -

#12 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1152
  • View blog
  • Posts: 2,529
  • 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.
Was This Post Helpful? 0
  • +
  • -

#13 Redwizard000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#14 Theomi  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 88
  • 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 :P

	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;
	}

Was This Post Helpful? 1
  • +
  • -

#15 idkau  Icon User is offline

  • New D.I.C Head

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

Re: Proper variable names!

Posted 24 June 2012 - 10:29 PM

that hurt my brain lol
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2