|
|
|
|||||
|
Static Functions
Hi,
Am I missing something obvious, or is there no support for static or class functions? If this is indeed the case, I've got two questions: 1) Why? 2) Do you have suggestions on _clean_ bootstrapping to obtain object references? Thanks in advance, -- Andrew Bell andrew.bell.ia@gmail.com |
|
|||||
|
Quote:
Do you have other suggestions for handling such a case? |
|
||||||
|
Static functions have no place in distributed systems. Consider two Car proxies, that point to Ice objects implemented by the same physical server. A static function means that if you call on either of the two proxies, you get the same response, since both Car implementations operate on the same static class data.
Now consider that the server is redeployed, and the two Car Ice objects are moved to different physical servers. Such a change must be transparent to the client. However, with static functions, such transparency is lost: If you call on the two proxies, you now get different results, because each proxy points to a different server that operates on different static class data. Static functions also destroy language transparency. Given a Slice-defined interface Car, implementations can be written in C++, Java, or any other supported language, regardless of the programming language used for the client. But you cannot support static functions across different languages. So if you have some Cars implemented in Java and others in C++, you again cannot have all implementations return the same results for the same static function calls. In any case, the solution to the problem is simple: Define a singleton class such as CarInventory, that holds a list of proxies for all Cars. Instantiate only one single Ice object for CarInventory. Then your clients can access this CarInventory Ice object and get a list of all Cars, regardless of where or how the individual Cars are implemented. |
|
|||||
|
What you are implying, I think, is that server-side static data is a bad thing. Perahps if you have implementations on various servers or across various languages, it is (though syncronizing server data is not always unreasonable).
Still, I would bet that a system with a single server written in one language is the norm, not the exception. In such an enviornment, static data (and hence functions) make a lot of sense - it's just like you were writing a single application, where you have farmed out some of the work. I just think it would be incredibly convenient for the system to create a "default" proxy which isn't bound to an implementation object for each class that had a "static" function. This would eliminate the singleton class on both the client and server that serves no purpose than to transport the static data. If you have a truly distributed server implementation then you always have the option NOT to use the static data, but it would simplify things for the rest of us. Cheers, -- Andrew Bell andrew.bell.ia@gmail.com |
|
||||||
|
I do not imply that server-side static data is always a bad thing. This is a valid implementation choice for some designs. Ice separates implementation from interface, and for the reasons I outlined, static member functions have no place in a Slice interface definition. However, you can implement an interface defined in Slice as a singleton that accesses static server data.
|
![]() |
| 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 |
| Overloading functions in slice | Sameerrele | Help Center | 3 | 09-05-2006 04:10 PM |
| Static linking (again) | joe | Comments | 2 | 06-02-2006 09:26 AM |
| Idle functions possible? | coke | Help Center | 1 | 01-26-2005 04:34 PM |
| Need these functions: | motoyang | Comments | 1 | 11-23-2004 04:24 PM |
| vc static lib | hellocyf | Help Center | 2 | 08-04-2004 11:53 PM |