OOP in Rev...
mark at maseurope.net
Thu Mar 20 09:24:30 EDT 2008
Viktoras, you can effectively hide the array manipulations in a
library stack. I've done this quite a lot, though haven't really
thought of it as OOP-like, though it produces at least some kind of
'encapsulation'. One could think of the library stack as being the
place where you define 'classes'.
Just off the top of my head, the script of the library 'class' stack
might look like this :
local sCityProperties =
on setCity pCity, pProp, pVal
if pProp is among the items of sCityProperties then put pVal into
function getCity pCity, pProp
if pProp is empty then put "all" into pProp
return sCities[pCity, pProp]
function allCityData pCity
put the keys of sCities into tKeys
filter tKeys with pCity & "*"
repeat for each line L in tKeys
put item 2 of L & "=" & sCities[L] & cr after tCityData
put popDensity(pCity) after tCityData
function popDensity pCity
return sCities[pCity, population] / sCities[pCity, "area"]
so then in the main app, you'd do things like :
setCity "London", "country", "UK"
setCity "London", "population", 8000000
if getCity("London", "populationDensity") > 34 then....
which is sort of equivalent to :
London.population = 8000000
if London.populationDensity > 34 then....
Forgive me if this is all stuff you've already done, but it's
certainly helped me think about it a bit!
On 19 Mar 2008, at 14:19, viktoras didziulis wrote:
> me too like rOOP, but I feel it is a little incomplete, just one
> more step. The ones that you call real objects are limited to user
> interface controls only. The thing I was curious about is a
> possibility to create an independent data object which is nor
> control neither a gui element. Which in this case may simply mean
> enhanced arrays...
> What for ?. I think this would make code cleaner and reduce
> amount of commenting in larger projects.. Also facilitate creation
> or adoptions of existing libraries in C or C++ for very specific
> purposes - like reading shapefiles, netcdfs, doing geographical
> transformations, astronomy, bioinformatics, etc... This
> consequently will increase the scope of applications that can be
> created in Rev and hopefully availability of diverse libraries.
> In general it would make creation of complex software easier. We
> can already simulate objects using arrays, but at least the code
> would be more readable (!!!) if I were able to distinguish array
> operations from object manipulations.
> Best wishes
> Mark Schonewille wrote:
>> I just don't get it. I never ever felt a need for OOP and I just
>> can't imagine I ever will, using xTalks. I'd call xTalk rOOP
>> (really object oriented programming) because xTalk uses real
>> objects, like fields, buttons, etc.
>> Why don't you simply forget about OOP? What does OOP have that
>> rOOP doesn't?
>> Consultancy and Software Engineering
>> Get your store on-line within minutes with Salery Web Store
>> software. Download at http://www.salery.biz
>> Op 19-mrt-2008, om 13:25 heeft viktoras didziulis het volgende
>>> 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...
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
More information about the Use-livecode