From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,82b509356384c38b,start X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,82b509356384c38b,start X-Google-Attributes: gid103376,public From: shanem@netcom.com (Shane Miller) Subject: READ 1ST: use eiffel for CAM library development? Date: 1998/01/21 Message-ID: X-Deja-AN: 318157957 Sender: shanem@netcom9.netcom.com Organization: Netcom On-Line Services Newsgroups: comp.lang.eiffel,comp.lang.ada Date: 1998-01-21T00:00:00+00:00 List-Id: sorry -- the other version i wrote was rushed and a little unclear. i rewrote it here and make it more focused. this message, while written for eiffel, still applies to ADA-95. i am very curious to know how non C++ people handle the following two scenarios, especially the object-shareing issue. garbage collection is sold as a feature on most OO languages totally without context and without discussing the impact. thanks very much shane miller ------------------------------------------------- hi: i am trying to examine the possibility of using eiffel or ADA-95 in place of C++ for a library development project. the main challege (in this library) has to do with: * event driven decision making * object sharing and copy-reference semantics what is the recommended methodolgy under eiffel for these two scenarios: SCENARIO 1: event driven "business logic" an object of class A wants to change the state of an object of class B. however, B knows that it must consult objects from class C and D first to see whether the requested change is ok. B knows that it must consult C and D first only because C and D found B and registered themselves with B saying "if anybody tries to change your state you must consult with me first to see if i allow it. if i do not then you cannot make the change". also, an object from class E has found object B and says "notify me only if your state changes. i don't care what the change is; just notify me after you've changed". ok, A sends a message to B and says "change age to 10". this generates two messages: one event is sent to C and one to D saying the "proposed change is age<-10, is this ok?". if both C and D say yes, then the age is changed which generates another message: an message is sent to E saying "age was changed to 10". how does this work under eiffel? (under C++ function ptrs, functors, and object references or pointers are used for objects A,B,C,D,E). also, under C++ i would have "controller" objects to facilitate the messaging and "business objects" to contain things like "age". this is after NeXT's approach of willChange and didChange messages plus controller objects which delegate work to business objects. SENCARIO 2: object sharing and object copying. you are writing a library. in your library you maintain a very important list. each item in the list is large say around 5K. you have another list also very importnat which contains around 100K items but each item is real small, say, around 50 bytes. these lists are important so you need to make them available to client programmers who might want to inspect them or make a computation based on them. Question 1: how do you make each list available to a client programmer without allowing the client programmer to change the list or the state of a object in the list? this is important because changing the list could have a big impact on the rest of the items in the list (eg. the list is sorted; the list is spatial). so the only way a client can alter the list is to make another library call in which the list is changed as a side effect. Question 2: the user for a computation needs to obtain a copy one of the lists. he needs to do this so he can change the state of an object or two and then update a result in some part of his program. how can the client programmer get a copy of the list with a minimum of a performance hit? (in C++ we would implement question 1 using a iterator allowing the client programmer to call "const" only functions and const only functions on the list's contents. therefore with no copying he has read-only access to the list [in C++ he could cast away the const and do something wrong too]. for question 2, we would implement the object in the list using reference counting and copy-on-write. so if the user wanted a copy of the short-list but with big objects, only the objects he *ACTUALLY CHANGED* got copied; all the others are still have a reference to the libraries version. same with the long list but with small objects. in either case only the energy which is needed is actually expended). i hear a lot of "bravo " about garbage collection in eiffel but i never hear anything on these real major-league problems. i have order the eiffel book whicj talks about library development. i will very interested in reading what it says about this crtical problem in library design. obviously this critical not only for the library designer by the client programmer too -- -------------------------------------------------------------------- shanem@netcom.com | Remember: know where you're going and then who's 804.673.4966 | going with you. Never get the order mixed up. -------------------------------------------------------------------- Beware of the software trap: because I can do x, I should be doing x --------------------------------------------------------------------