Scripting style: Verbs in function names

Phil Davis revdev at pdslabs.net
Thu Nov 3 19:21:10 EDT 2016


I like Devin's reasoning on this. One of the great benefits we enjoy in 
using LiveCode is the "English-like" syntax. This is one of LC's 
hallmark features. As I see it, we should work to preserve it and extend 
it in our naming of commands and functions.

My 2 cents' worth -
Phil Davis


On 11/3/16 4:00 PM, Devin Asay wrote:
>> On Nov 3, 2016, at 4:16 PM, Monte Goulding <monte at appisle.net> wrote:
>>
>> Hi LiveCoders
>>
>> In a PR I have open Peter has asked me to `Please name this function with a verb` and I recognised that in LiveCode this is something I don’t do out of habit while in other languages it is. Why? Because in the context the a function is used there is already a verb in the statement in our language. I definitely think verbs should be used for custom handler names though. It seems to me that if my gut feeling and what I’ve been practicing for a long time is seen as general best practice for the community then it should be documented.
>>
>> I notice that there’s a mix of noun and verb engine functions.
>>
>> What do people think:
>>
>> put GetSomething() into container
>>
>> or
>>
>> put Something() into container
>>
>> BTW I’m happy to change my ways I’m just curious what people think.
> Almost all commands are imperative verbs:
>
> go
> do
> set
> put
> import
> grab
> etc.
>
> Most built-in functions tend to be nouns:
>
> date
> time
> focusedObject
> folders
> files
> functionNames
>
> And some functions are adjectives:
>
> random (although you could argue this is a nominalized adjective)
> licensed
>
> Some functions are even predicate phrases, camel-cased:
>
> isNumber
>
> And there are a few functions that are verbs:
>
> flushEvents
> getResource
>
> I think the best function names are the ones that “read” naturally in a statement:
>
>    put the random of 10 into myVar
>
>    if isCorrect(fld “answer”) then…
>
> So when I name commands I use verbs. When I name functions I tend to use nouns or predicate phrases, whatever reads like natural x-talk.
>
> Devin
>
>
> Devin Asay
> Director
> Office of Digital Humanities
> Brigham Young University
>
> _______________________________________________
> 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

-- 
Phil Davis





More information about the use-livecode mailing list