|
|
|
|||||
|
The nonmutating method hint is a little bit confusing to me.
It is said (p.83): interface Clock { nonmutating TimeOfDay getTime(); void setTime(TimeOfDay time); }; Quote:
You also explain that the nonmutating hint means that (given a set of parameters ?), the method can be called more than once before returning without harm: I understand that this is the interface designer choice to make some methods nonmutating or not, and that this choice is often made with an implementation in mind. For example, it effectively does not harm to call getTime() many times, even if the Clock implementation on the server is a real-time Clock (and not just an object with a TimeOfDay property). The same reasoning may apply to interfaces that do not store any state by themselves, for example a proxy to make predefined requests to a database, even if the result may be different between the different call attempts. Is this point of view compatible with your definition of the nonmutating keyword? -- Christophe |
|
|||||
|
Thanks for your quick answer.
I better understand the implications and the benefits of the nonmutating and idempotent keywords now, but let me be more specifics: I am in the process of writing some best practices, or guidelines, for developers and architects that where accustomed to work with CORBA. Among the subjects i want to clarify is the good use of the nonmutating keyword, and i was w(a)ondering if: Is it recommended / permissible / forbidden to use nonmutating methods for objects that do not hold state by themselves and whose return value is always the result of a "best effort", a situation which i guess is also idempotent (in the spirit of my db request example). Because from my point of view it is safe to call such method more than once, a nonmutating method is permitted. The expected added-value being that the retry process is done by the Ice runtime, and not by a developer. But, even in this situation, there is some internal limitations, or use cases (like using Freeze) that i am not aware of, so your advice is valuable. -- Christophe |
|
||||||
|
Quote:
So, if reissuing the database request does no harm, then you might as well mark the operation as nonmutating. In essence, nonmutating captures the idea of (logical) const-correctness -- even though the physical state may have changed somewhere, if that state change is semantically invisible to the clients, the operation is conceptually nonmutating (even if a reissued request may return different data). Using idempotent and nonmutating keywords has the benefit of giving you better error recovery and, in addition, for C++, you get slightly better type safety because the corresponding member functions on the skeleton become const member functions. Cheers, Michi. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| name.Endpoints semantics | mwilson | Help Center | 1 | 07-18-2005 05:11 PM |
| More subcommands needed in icepackadmin! | rc_hz | Help Center | 0 | 11-16-2004 12:59 AM |
| Semantics of pass by value for interface | chaukmean | Help Center | 2 | 11-27-2003 06:21 AM |
| semantics of slice2java --depend | manfred | Bug Reports | 0 | 05-21-2003 03:49 AM |
| Documentation : At-most-once Semantics | dipakyadav | Bug Reports | 4 | 02-21-2003 06:16 AM |