Hacker News new | ask | show | jobs
by stcredzero 6434 days ago
Often when competent programmers are having trouble grasping pointers, they are actually doing fine with thinking about pointers in abstract, but having trouble with the notation describing a particular instance of them. (Especially with C programs.)

One of the things that doing good OO and following the Law of Demeter does for you is to reduce the levels of indirection you have to deal with to one or two.

2 comments

From what I've seen helping people I know handle pointers, they're really actually having trouble with the concepts of pointers. Getting them to draw the box diagrams with pointers correctly is challenging. The notation is an extra challenge, but it's not the main difficulty.

It's not the notation, it is the concept.

Only time I've seen difficulty with pointers in the abstract is when helping people in intro programming classes in C. Once you're past that level, programmers get it, but they get confused by what the code is actually saying.
What really helps in that situation is a good debugger, that lets you quickly look up blocks of memory (e.g. where the pointer references). Obviously it should be stable enough to handle bad pointers (giving an error message instead of crashing is nice).

The old CodeWarrior debugger was great for this. Lots of windows you could pop up for every in-memory object you cared about. sigh

You should take a look at ddd. I've never used CodeWarrior, but from your description it sounds a lot like ddd.
ddd's nice, but CW made it a lot easier to stay close to the machine-level. Nothing like a good window'd hexdump to browse :-)