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
> 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.
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
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)