OOP in Rev...

Thomas McGrath III 3mcgrath at comcast.net
Wed Mar 19 08:40:07 EDT 2008


I have not tried this in Rev but I was thinking that you might want to  
mix the array with custom props so that the array set the custom props  
of the object. The array could build the object and it's properties.

Just a thought.

Others on the list will have more experience with this.


On Mar 19, 2008, at 8:25 AM, viktoras didziulis wrote:

> I would like to define a class, an object (the both with their  
> properties) and methods that are not a part of graphical user  
> interface or Revolution engine...
> Let's say I need an object "City" having properties: minLatitude,  
> maxLatitude, minLongitude, maxLongitude, area, populationSize,  
> growthRate, dateFounded, currentDate so it can be handled using  
> specific handlers and functions (e.g. its methods). Or, well, it  
> would be more correct to start with creation of a class "City" or  
> "templateCity" and then use it to create new "city" objects  
> (NewYork, Paris, etc...) that can be processed by their functions  
> like "populationGrowth(Paris, start_year, end_year)" and so on...
> The three approaches that I can imagine are somehow inter-tangled:  
> (1) creating an object as a custom property set of a stack or (2)  
> creating it as an array or (3) creating it as an invisible control  
> with custom properties. But all these have their drawbacks.
> The (1) and (3) approach allows attaching handlers to custom  
> properties and allows accessing object (e.g. a custom property set)  
> properties using both an array notation (somehow an equivalent to an  
> array-like behavior of objects in javascript) and in a way  
> consistent with handling of properties in Rev e.g. "set the .. of ..  
> to ..." or "get .. the .. of ...". Unfortunately (1) allows only a  
> single object to be active and thus accessible. The (3) is a dirty  
> one, because object is created using empty controls with their own  
> additional properties and methods. The (2) looks promising, one can  
> create a class, write a constructor function that would create new  
> objects from the class, etc... But it lacks consistency with the  
> existing OOP style in Rev - e.g. you can not get or set an element  
> of an array using "get the <element/property> of <array/object>" or  
> "set the <element/property> of <array/object> to <value>". Besides  
> you can not use getProp or setProp handlers with array's elements.
> Did anyone try doing something like this kind of OOP in Rev? I would  
> appreciate if you can share your thoughts, warnings, tricks and  
> approaches :-). I am not looking for a complex C++ like style of OOP  
> in Rev. Anything simpler like the OOP model of javascript would be  
> OK. In general, I think, it would be nice if one could treat and  
> access Revolution arrays as objects with custom properties, with all  
> the getProp, setProp and templateObject stuff... Or is it possible  
> somehow? If not, is this already posted to QC as an enhancement  
> request - I would vote for it? Otherwise going to post it there  
> myself...
> All the best!
> Viktoras
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

More information about the Use-livecode mailing list