-
Notifications
You must be signed in to change notification settings - Fork 28
Use constructors for WoT objects #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
what makes you assume that? A binary switch has state. Perhaps you are using state in a specialised sense, if so could you please explain. |
Misunderstanding. I meant the root WoT object. It doesn't have properties, only functions. |
Wouldn't it be necessary to have separate interfaces for the "object creation" and "exposed"? |
They would be separated: I am not saying this model is better than factories (I am also coming from the embedded end), but that
|
Of course until decided, we can stay with the current way (factories). This issue is for tracking the discussion for this option. We may also seek external opinions on this. |
+1 to making The pattern of having a promise-returning function create a constructible object, call its asynchronous initializing method (here |
In my NodeJS app server, to publish a thing, I call a function with the name of the thing and the JSON for its description. The library then invokes a call back with the object created based upon the description, and publishes it on the server. This makes it discoverable using a URL for the given name. The application script then initialises the bindings for the thing's properties actions and events. Note that this process is asynchronous since the new thing may depend upon other things, e.g. when this thing has other things for some of its properties. This then requires the library to access the descriptions for those things and instantiate them as objects for this thing's application script. I would like to know if anyone other than me has implemented support for having things as the value of properties? I think I agree with making registration with a remote registry into a separate step under the control of the application as you may not want to register all of the things in that way. |
I don't have a lot of context here, so my apologies if I get something wrong. This is all rather abstract, with talk of things instead of concrete examples. But here are my thoughts:
So, although I am normally in favor of constructors, from what I can gather here, it seems like they are not being used to actually construct the object with all of its relevant data; they are being used as part of a builder pattern of some kind. The original design makes more sense to me from that perspective. |
@domenic thank you for the guidelines! |
…finitions according to commints in w3c#3. Signed-off-by: Zoltan Kis <[email protected]>
we had two main rationales for having the rather unusal design of factories that return promises is as @domenic mentioned that you normally do not expect a constuctor to fail and its synchronous. The methods like the factory that is taking in an URI, downloading the thing description and then creating thing for it can fail for many reasons and are based on asynchronous operations. There are the simpler versions which are now modeled in the same way for homogenity - i agree we could as well do constructors for them and also we might consider to move them to static factories on the respective classes. The reason for the single-entry object was twofold: keeping global clean (which can also be done with a namespace as @tobie mentioned) and providing a single entry point as convenience feature (only need to remember WoT instead several classes) |
I think this needs much more discussion and eventually agreement with IETF (and maybe W3C to really simplify things). For now, I see value in building on existing, international, open Internet standards and that new concepts get new names. However, it is always good to simplify things... In an offline discussion, I would be interested in how you plan to obsolete RFCs from within the WHATWG. |
That does seem out of scope. Let's be clear though that we won't be shipping new web platform APIs that don't converge on the URL spelling. |
Yes, I think I fixed these in #7. There are many ways on how to go forward, but I've got the point about the URL naming. |
Closing issue as discussed in scripting call on 27-03-2017 |
Uh oh!
There was an error while loading. Please reload this page.
Since WoT is going to be implemented on different types of runtimes (see also #2),
and since the root [1] WoT object has no state,
arguably it would be simpler to expose the WoT object with a constructor (internally implementations could still use a singleton).
Also, for
ExposedThing
andConsumedThing
we could provide constructors instead of factories. That would be more aligned with ECMAScript best practices (e.g. anExposedThing
object could be created for testing purposes, shaped locally, then exposed).Currently the interface uses factories:
It could be changed into:
[1] edited: s/Wot object/root WoT object
The text was updated successfully, but these errors were encountered: