Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What is a 'BackPointer'?

1,397 views
Skip to first unread message

john-...@hlp.com

unread,
Oct 6, 1997, 3:00:00 AM10/6/97
to

What do people mean when they use the term 'BackPointer'? I mean, what
sort of 'pattern' or model are they using that distinguishes 'back' and
'forward'?

I'm trying to get my 'arms around' OO! Between the mutable/immutable and
proxies, adapters, bridges, etc, I'm having a time of it!

Thanks,
John

-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet

Philip C Plumlee

unread,
Oct 6, 1997, 3:00:00 AM10/6/97
to john-...@hlp.com

john-...@hlp.com wrote:

> What do people mean when they use the term 'BackPointer'? I mean,
> what
> sort of 'pattern' or model are they using that distinguishes 'back'
> and
> 'forward'?
>
> I'm trying to get my 'arms around' OO! Between the mutable/immutable
> and
> proxies, adapters, bridges, etc, I'm having a time of it!

This is not really an OO thing (although it is just as useful as loops
or IO or other predecessors to OO). It is a dynamic memory thing.

The bad way to allocate dynamic memory is to call 'new' a lot and never
call 'delete'. Yes, some do it, because the OS cleans up after them.

The correct way is to build a tree in memory where one big object, like
'SimCity', contains collections of smaller objects, like 'SimBuilding'
and 'SimGang'. These now contain leaf objects like 'SimOffice' or
'SimDeala'. In terms of ownership, the destructor for 'SimCity' frees
all the buildings; their destructors free all the offices.

But if I have a pointer to an Office I might need to determine which
City or Building it is in. Each non-root object contains a pointer to
its owner. Given an Office, I can dereference twice to obtain an
interface to the root 'SimCity' object. The alternative is to pass a
reference to a City _and_ a Building into _every_ function that deals
with Offices, because (now or someday) some called function somewhere
might need this ownership information.

Backpointers are link pointers; never owner pointers. Imagine the
disaster if an Office tried to delete the building around it!

This is not an OO thing because the true meaning of OO is interface
polymorphism. Ownership and chains of reference of dynamic memory, like
structured logic, is a lower level programming concept.

-- Phlip
====== http://users.deltanet.com/~tegan/home.html ======
My web page now contains 20 pages of original comics; many many more
are on the way. Whatever you think they are like (sci fi, action,
super-hero, etc), they are not.


Chris Coakley

unread,
Oct 6, 1997, 3:00:00 AM10/6/97
to

If I am wrong here, someone please correct me.
A back pointer is like the "this" pointer that is passed implicitly in
C++ functions. It provides a pointer for the called function "back" to the
class that called it. That way the function has the access to the data of
the class. Used explicitly, it states "Hey, give me a pointer back to
whatever calls me so I can do something usefull." Of course, what I am
saying is just what I would think of if it were a test question and/or I had
no desire to look it up anywhere. If I had the actual context of where you
came across this term, I could be of much more help. Actually, If I am
right, someone please state so.

If that's all right, then I hope that answers all your questions.

--
Christopher J Coakley
ucoa...@mcl.ucsb.edu

john-...@hlp.com wrote in message <8761631...@dejanews.com>...


>What do people mean when they use the term 'BackPointer'? I mean, what
>sort of 'pattern' or model are they using that distinguishes 'back' and
>'forward'?
>
>I'm trying to get my 'arms around' OO! Between the mutable/immutable and
>proxies, adapters, bridges, etc, I'm having a time of it!
>

>Thanks,
>John


Dave Aronson; remove antispam Xs to reply

unread,
Oct 7, 1997, 3:00:00 AM10/7/97
to

(Newsgroups trimmed to those I read -- down with crossposting!)

Philip C Plumlee <te...@deltanet.com> writes:

> Backpointers are link pointers; never owner pointers. Imagine the
> disaster if an Office tried to delete the building around it!

But one might WANT to simulate a large bomb going off in an
office... isn't that why you also mentioned SimGangs? B-)


-Dave Aronson, Sysop, Air 'n Sun (airnsun.pcbuddy.com), @ (703) 319-0714
SUPPORT REP CHRIS SMITH'S NO-JUNK-EMAIL BILL! GIVE A DAMN, DON'T SPAM!
Opinions MINE, not from Template, Mensa, NRA, SCA, US Gov't, or God!
http://www.webspawner.com/users/DaveAronson/ (last updated 1997-10-01)

0 new messages