Hi,

I've been using the restlet framework for a while now, and it's a  
really well-written system, I really like it.

However, I got a nasty surprise the other day when I tried to do  
something like this:

1  Reference ref = new Reference("/foo");
2  doSomethingWithRef(ref);
3  doSomethingElseWithRef(ref);

I got strange behavior on line 3, because line 2 mutated the reference  
created in line 1, so it was no longer '/foo'.

This was a surprise to me, because I've been working with functional  
languages quite a lot recently and they just don't behave this way,  
and avoid a lot of nasty side-effects as a result.

I agree that it's a nice design to use a reference to derive another  
reference, eg.

Reference ref = new Reference("/foo");
Reference ref2 = ref.addQueryPath("bar=zip");

But it would be really cool if Reference instances were immutable  
because then you could safely re-use them, and it would be easier to  
avoid bugs when writing restful apps.
In example above, adding a query path shouldn't change the original  
reference.

Thanks,

Malcolm

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1125259

Reply via email to