[Gambas-user] An other problem with object oriented approach.

Jussi Lahtinen jussi.lahtinen at ...626...
Sat Dec 13 21:37:30 CET 2008


Ok, thanks!
Those items have unique long type id number.
Maybe I'm wrong but to me string keys sounds slow.
Perhaps binary mode is quicker (
http://gambasdoc.org/help/comp/gb/collection/_new?show ).
But I think this is the right way to go!

I didn't find this from documentation, so do anyone know what $ sign
means at declaration.
Example:
PRIVATE $iTotal AS Long


Jussi


On Sat, Dec 13, 2008 at 9:22 PM, Fabien Bodard <gambas.fr at ...626...> wrote:
> yes you soluce is collection
>
>
>
> 2008/12/13 Werner <wdahn at ...1000...>:
>> Jussi Lahtinen wrote:
>>> Hi!
>>>
>>> I'm converting Vb6 project to Gambas.
>>> And because Gambas doesn't have UDT/structures, I have to rethink some
>>> of the code (not necessary bad thing).
>>> I'm converting some parts of the code to object oriented way.
>>> But I run into some problems with it.
>>> I have module which contains mainly global arrays and global UDT arrays.
>>> That module describe items, every item is identified by index number.
>>> Like this (vb6 code):
>>> Global Alive(Max_Number_Of_Items)  as boolean
>>>
>>> So if I want to know if item 2 is alive, I'll write:
>>> IF Alive[2] = TRUE THEN
>>>
>>> Problem is in identification, items have to know who is who.
>>> Old array based code is something like this:
>>>
>>> IF Alive[Who] = TRUE THEN
>>> ComWith = CommunicateWith[Who]
>>>   IF Alive[ComWith] = TRUE THEN
>>>   WhereX[ComWith] = ...
>>>   WhereY[ComWith] = ...
>>>     ...
>>>
>>> And when I want to save/load items to/from file, I use Id <--> Index
>>> translation function which translates CommunicateWith array with ID
>>> array.
>>> But that is way too slow to use at normal execution, it is useful only
>>> on file operations.
>>> If I convert these items to objects, there is not much point to use
>>> Alive array (etc.), I'll just remove dead items and add new one only
>>> when needed. But that creates problem with identification, since I
>>> can't use index numbers anymore!
>>> And looping every item to see if it have right Id number (that matches
>>> to CommunicateWith[WhoEverAsk]) is way too slow (like in
>>> Id <--> Index translation function).
>>> Slow because there are many(!) items, and every item should be checked
>>> against every item!
>>>
>>> So, any ideas how to implement fast identification between objects?
>>> Other words, how to translate Id to Index without looping?
>>>
>>> I'm trying to learn object oriented style and right now it's very
>>> difficult to stretch my brains around it...
>>>
>>>
>>> Jussi
>>>
>> If there is anything unique in your items you could use a collection
>> instead of an array and use the unique part as a key.
>> Werner
>>
>>
>> ------------------------------------------------------------------------------
>> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
>> The future of the web can't happen without you.  Join us at MIX09 to help
>> pave the way to the Next Web now. Learn more and register at
>> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
> ------------------------------------------------------------------------------
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
> The future of the web can't happen without you.  Join us at MIX09 to help
> pave the way to the Next Web now. Learn more and register at
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>




More information about the User mailing list