Refactoring

Bob Sneidar bobsneidar at iotecdigital.com
Thu Jan 29 16:29:39 EST 2015


The code 10 years from now:

scanMind(currentThought, currentObject, applyNow)

All the code you will ever need.

Bob S


On Jan 29, 2015, at 09:29 , Geoff Canyon <gcanyon at gmail.com<mailto:gcanyon at gmail.com>> wrote:

Small thing, but I just turned this twelve-year-old code:

     put "Double-Click:" into tProperty
     if the optionKey is "down" then
        if the commandKey is "down" then
           put "Option-Command-Double-Click:" into tProperty
        else
           put "Option-Double-Click:" into tProperty
        end if
     else if the commandKey is "down" then
        put "Command-Double-Click:" into tProperty
     end if

into this:

     put "Double-Click:" into tProperty
     if the commandKey is "down" then put "Command-" before tProperty
     if the optionKey is "down" then put "Option-" before tProperty

I love turning ten lines of code into three lines of code. I hope twelve
years from now I can look back at those three lines with the same degree of
horror I feel now looking at the ten-line implementation.




More information about the use-livecode mailing list