Subscribe to Stuck in an Infiniteloop        RSS Feed
***** 1 Votes

Code "Guessing"

Icon 5 Comments
We've all done it. It's almost a rite of passage, but it needs to stop. Guessing at code means you've abandoned all paths of knowledge and logic and are now flailing hopelessly at some code.


Case in point, pointers. Who hasn't seen a error message like this?

Quote

error C2440: '=' : cannot convert from 'int' to 'int *'


There used to be a time, for all of us, where we'd start throwing * &'s around hoping the error would magically go away and the wizard who lives in the computer, whom we have somehow angered, is now calmed.

Do not guess! If you don't know what the issue is ask. If you don't understand a concept, read about it. When you're making a 2D array of pointers pointing to pointers because you misused a typedef, you need to take a step back! Get the concept to work at the simplest level and progress from there.

- A single pointer to a single object.
- An array of pointers to objects.
- A pointer to a pointer of an object.
- An array of pointers to pointers of an object.

Use a logical progression. Jumping around, throwing your arms up, and throwing in random bits of code makes about as much sense as skipping steps when defusing a bomb. Don't do it.

5 Comments On This Entry

Page 1 of 1

moopet 

20 May 2010 - 12:02 PM
I prefer to think of it as using the Force.
0

Locke 

20 May 2010 - 04:49 PM
I don't prefer to think of it as using The Force...I just use The Force. :)
0

mostyfriedman 

21 May 2010 - 09:02 AM
Good read KYA.. I totally agree
0

sarmanu 

21 May 2010 - 10:42 AM
I so much agree with you :)
0

eZACKe 

26 May 2010 - 11:47 PM
I think what you're referring to is Voodo Magic :magic:
0
Page 1 of 1

November 2020

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
29 30      

Tags

    Recent Entries

    Recent Comments

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)