Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > Re: Name of cla...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 9 Topic 35490 of 37137
Post > Topic >>

Re: Name of class instance

by VK <schools_ring@[EMAIL PROTECTED] > May 6, 2008 at 05:00 AM

On May 6, 3:25 pm, Matthias Watermann <li...@[EMAIL PROTECTED]
> wrote:

> The main question, however, is whether JavaScript
> provides a way to let an object figure out its name. I understand
> that's not the case, right?

Right - because there is not such thing as "instance name". In this
aspect Javascript is no any different from any other programming
language like say C++ or Java. There is an instance object, and a
reference to this instance can be assigned to different identifiers or
you even may keep it anonymous, say
 (new childOne).aMethod();
- not to say this approach is used too often, just to help to separate
in your mind a reference identifier and the object itself.
Of course each instance has its own objectID (DispID) to distinguish
several instances of the same class, but it is an internal system
property which is not accessible from the language itself. Again, it
is not any different from other OO languages.

>
> > [...]
> > From my rather long experience which you are free to disregard of
> > course,  the "necessity" to know the current instance reference
> > identifier is a strong indication that the current programming pattern
> > is targeted straight to hell where it will sooner or later ;-)
>
> Well, I can't reject that, of course. In my case the object's name
> is needed for sending it (along with other data) back to the web-server
> which returns a piece of JavaScript code invocing an instance method
> (the name and API of which is defined by contract). And since there may
> be several concurrent requests (by different objects) I've to make sure
> somehow that each response reaches the respective requester.

A month later I would suggest to use WebService mechanics for that,
but now I see confirmed that Firefox 3.x will not have it as a default
feature for whatever reason:
http://developer.mozilla.org/en/docs/Accessing_Web_Services_in_Mozilla_Using_WSDL_Proxying

So just stick then with manually setting initial instance identifier
on object instantiation. It is very bad and all hell doors may get
loose if more than one reference to the same object, but if you are on
a time limit...

For a long right run it is not instance business to handle RMI (Remote
Method Invocation), they have to do their job right first. For RMI
there should be a separate dispatcher. This way an instance sends
request to the dispatcher with reference to itself as request
consumer. The dispatcher then handles the request queue and returns
results to consumers by stored references.
This way you don't care what identifier(s) is(are) currently used to
hold a reference to the object which is the proper way to do things.
 




 9 Posts in Topic:
Name of class instance
Matthias Watermann <li  2008-05-06 09:31:19 
Re: Name of class instance
Henry <rcornford@[EMAI  2008-05-06 03:05:30 
Re: Name of class instance
VK <schools_ring@[EMAI  2008-05-06 03:09:03 
Re: Name of class instance
Matthias Watermann <li  2008-05-06 13:25:21 
Re: Name of class instance
Thomas 'PointedEars' Lahn  2008-05-06 21:46:55 
Re: Name of class instance
VK <schools_ring@[EMAI  2008-05-06 05:00:58 
Re: Name of class instance
Matthias Watermann <li  2008-05-06 15:17:07 
Re: Name of class instance
sheldonlg <sheldonlg&g  2008-05-06 10:48:00 
Re: Name of class instance
Matthias Watermann <li  2008-05-06 17:51:57 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 16:19:18 CDT 2008.