swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C/Java Translation


From: Paul E Johnson
Subject: Re: Objective-C/Java Translation
Date: Wed, 24 Jan 2001 08:56:49 -0600

> Rob Leclerc wrote:
>  
> "<interfaceName>","<interfaceName>C","<interfaceName>CImpl","<interfaceName>Impl".
> 
> As well as these "C" references, which I take to be some kind of
> create versions of the class, there are also some "S" type classes.  I
> was unable to get a good understanding of what the different or
> important roles these classes played. > 

Hey, Rob, I'm trying to understand this too, a late Java-arriver as I
am.  Perhaps I can write down my understanding, we can get corrected by
the experts, and I'll have something to put in the FAQ.
  
If you look in the Email list from early January, you will find a note
from me asking how to subclass Arguments in java and Marcus gave a test
program, which I have in the WorkingExampleCode section of SwarmFaq.
http://lark.cc.ukans.edu/~pauljohn/SwarmFaq/WorkingExampleCode/java/ArgumentsSubclass.java
.

To the best of my limited understanding, the problem is Java
constructors do not allow return arguments, so the usual swarm thing
like: 

        [[aObject createBegin: aZone] createEnd]

does not work.  Also, swarm classes are designed with a separation
between methods you can do at "create time" from others, and those
create time methods have to be used before the createEnd, and never
after it.  I'm not a programmer, so pardon my terminology.  Its
something like this: you need to catch the object when it is still in
the gestation period and do things to it, before it is a full fledged
object.  That was easy in ObjC, not so simple in Java.

So you have to look harder at Marcus's code, and I'm still not sure I
understand everything about it, but the CImpl class is the functional
equivalent of a "holding class" that can be created and given a
proto-object of the sort you want to create (maybe proto is not the
right word. I mean it is an inchoate object, a part-of-the-way created
object. I mean it is the thing that createBegin returns in objc). This
"holding class" has the ability to execute the things that go into the
createBegin phase of object creation.

Suppose you need to create aObject, but it requires
createBegin/createEnd fussing.

First, declare that thing you want to end up with.

        WhateverImpl aObject;

Next, create the "holding class" which can do the create-time fussing
about with the proto-object. Note, the proto-object is created in the
argument to WhateverCImpl, so it is "hidden" inside there.  The
WhateverCImpl class does whatever it does to that object:

        WhateverCImpl aTemporaryObject =  new WhateverCImpl( new
WhateverImpl());  

Now, aTemporaryObject can do the things you need done in the create
phase of the proto-class that is inside it:

        aTemoraryObject.createBegin(aZone);
        aTemoraryObject.setSomeValue(aValue);
        
Then, when you are done with create-phase methods, you yank the
proto-object out of aTemporaryObject.  I don't know why the cast is
required here, but it works:

        aObject = (WhateverImpl) aTemporaryObject.createEnd();

-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]