Stylistic question.

Bob Sneidar bobsneidar at iotecdigital.com
Sun Jun 19 19:19:54 EDT 2022


Well code shared commonly between multiple objects should generally be in an object shared by those objects. That can be the card, stack, behavior or front/back script. The script of a group as well. 

For example I have a behavior for all my datagrids. Each datagrid has a property called gridconstants which is an array of all the things specific to each datagrid. The behavior handlers will get this property so that I can use generic terms in the behavior like cTableName and cPriKey etc. Now my behavior handlers like selectionChanged and such become universal to all my datagrids. Only one place to edit the handlers now.

If I need to do anything specific with a datagrid, I keep those handlers in each datagrid script. 

Sent from my iPhone

> On Jun 19, 2022, at 14:09, Brian Milby via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> One reason would be if you were trying to use behaviors so you could manage your code with a repository like Git.  This would greatly reduce the number of behavior scripts that you would create.  One app that work on has the code in the stack’s behavior script.
> 
> Sent from my iPhone
> 
>> On Jun 19, 2022, at 4:33 PM, Alex Tweedly via use-livecode <use-livecode at lists.runrev.com> wrote:
>> 
>> I've noticed that in a lot of the example code I've seen recently, there's a bit of a common pattern.
>> 
>> In the card script, there will be code like
>> 
>> on mouseUp
>>  switch the short name of the target
>>    case "first"
>>        doCommandFirst
>>        break
>>    case "another"
>>        doCommandAnother
>>        break
>>    case "lastnotleast"
>>        doCommandlastnotleast
>>        break
>>  end switch
>> end mouseUp
>> 
>> I've seen this in examples from Livecloud, Appli, the WebApp example from Steven/Michael, and a few other places.
>> 
>> I would generally have put this code in each button (or other control) directly, and I'm wondering whether there are advantages or preferences for one of those versus the other.
>> 
>> Thanks for any opinions,
>> 
>> Alex.
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


More information about the use-livecode mailing list