|
From: Tyler C. <ty...@wa...> - 2006-02-04 15:14:35
|
On Feb 3, 2006, at 8:59 AM, Sandro Magi wrote:
> On 2/3/06, Tyler Close <ty...@wa...> wrote:
>>
>> On Feb 2, 2006, at 3:21 PM, Sandro Magi wrote:
>> > I'm making a little headway with these schemas. I'm looking at
>> > org.yurl.Author at the moment since it seems to encapsulate most of
>> > elements: Link, Embed, methods, etc.
>>
>> Yes, the org.yurl.Author object is a good example to study to learn
>> about schemas.
>
> Unfortunately, it's not an entirely clear intro to the web-calculus=20
> for beginners; it hits you with too much at once (dynamically=20
> generated "objects" and the "missing" classes, revocation,=20
> deputization and authority management, etc.). We need a "hello world!"=20=
> type example.
Yes, despite being a small piece of code, it does cover almost all the=20=
features. You are surely also correct that a first example shouldn't=20
cover so much ground.
> I suggest an incrementing counter:
>
> public class Counter {
> =A0 int current;
> =A0 public int getCurrent() {
> =A0=A0=A0 return current;
> =A0 }
> =A0 public void add(int i) {
> =A0=A0=A0 current +=3D i;
> =A0 }
> }
The above class isn't Serializable, and so an attempt to construct an=20
object will fail since the server won't be able to save the created=20
instance to disk. The object also has mutable state, which needs to be=20=
put into a database record.
> As useless as this really is, it focuses on the core fundamentals:
>
> 1. web-calculus doc serialization of a class
> 2. generating a schema from a class definition
> 3. generating a custom stylesheet for a schema
> 4. invoking a method via POST
> 5. idempotency of GET and non-idempotency of POST
> 6. how the waterken server marshals arguments for you
>
> These strike me as the fundamentals that need to be grasped in order=20=
> to do anything in the web-calculus. Thoughts?
I think we need to add:
7. how the waterken server manages mutable state
After that, I think we've got a good list.
Perhaps the "Hello World!" example should be just that:
public final class
Hello {
public static String
getGreeting() { return "Hello World!"; }
}
Perhaps this example could then be mutated to:
public final class
Hello implements java.io.Serializable {
private String greeting;
public
Hello(final String greeting) {
this.greeting =3D greeting;
}
public String
getGreeting() { return greeting; }
}
And finally, to show mutable state:
public final class
Maker implements java.io.Serializable {
private String greeting;
public static Hello
make() { return new Hello(Global.create(new Maker())); }
public static final class
Hello implements java.io.Serializable {
private Key scope;
Hello(final Key scope) {
this.scope =3D scope;
}
public String
getGreeting() { return ((Maker)scope.query()).greeting; }
public void
setGreeting(final String greeting) {
((Maker)scope.update()).greeting =3D greeting;
}
}
}
Thoughts?
Tyler
---
The web-calculus is the union of REST and capability-based security:
http://www.waterken.com/dev/Web/
|