Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!bionet!apple!apple.com!casseres From: casseres@apple.com (David Casseres) Newsgroups: comp.sys.mac.programmer Subject: Re: HandleObject vs. 5+ meg of RAM and Virtual Memory Message-ID: <9028@goofy.Apple.COM> Date: 6 Jul 90 23:20:27 GMT References: <279@unf7.UUCP> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 50 In article <279@unf7.UUCP> shite@unf7.UUCP (Stephen Hite) writes: > If I have 5 or 8 meg of RAM and virtual memory (a.k.a System 7.0.2 > :-)) is it really *worth* the limitations of using HandleObject? > Some of limitations are (as taken from the MPW C++ Beta Manual): The reason for using HandleObject subclasses has little to do with the size of memory. The virtue of handles is that they avoid *fragmenting* whatever memory space you use. The virtue of HandleObjects, beyond that, is that they avoid the extreme tendency (on the Mac) of malloc to eat up memory. > 1. You can't "...declare global variables, local variables, arrays > members, or parameters of handle-based types (rather than > pointers to them)." This is not a problem. All your handle objects have to be declared as typed pointers and allocated with new, rather than being declared directly as objects with automatic storage, that's all. > 2. You can't use multiple inheritance (as discussed previously ad > nauseum). And despite what its partisans say, you can do a helluva lot of good object-oriented programming without it. > 3. "It is not possible to allocate an array of handle-based objects, > for example, new MyObjects[10]." Again, not a real problem. You have to write a loop to allocate each object, then stick its pointer into the array. No big deal, and remember, no one is saying you have to use handle objects for everything. Use them where they're useful. > 4. You cannot "...take a pointer to a field of an indirect class > (i.e., &x->y). This restriction includes the implicit use of > pointers by references, such as int& p = x->y." Gackhhh. Forgive my bigotry, but only a dyed-in-the-wool old-time C weenie, or a dyed-in-the-wool groping-for-the-future C** guru can even guess what that means you can't do! Us ordinary mortals can probably still do a lot of good OOP without doing whatever that is... Handle objects are very nice and very useful, when used where they are appropriate, i.e. for objects that might otherwise cause heap fragging. The also avoid the evils of malloc, but if you want to avoid malloc without using handle objects, you can still create a PtrObject class as explained in the d e v e l o p magazine article. David Casseres Exclaimer: Hey!