Building a Standard Interface Template

Create your organization's standard module

The first step to creating a standard template is to create a shared module with your standard routines in it. If your company is called “Acme” for instance it would make sense to make a module called “acme” and then your main routine always have: require("acme") The idea is your standard template should have small, well defined reusable routines that can be used again and again with each interface. Each interface should only require you to write a small amount of code to address what is different for that interface rather than copy-pasting a whole load of boiler plate code. A good strategy in your template library is to break down the functions into table name spaces. For instance say your company is called Prime One then your top level nesting name could be “p1”. Then you can group utility functions under this name like this:

p1={}

p1.height = {}
p1.allergy = {}

function p1.height.extractHeight(Msg)
   -- Implementation goes here
   return 10
end

function p1.height.extractWeight(Msg)
   -- Implementation goes here
   return 10
end

function p1.allergy.listAllergies(Msg)

   return 10
end

Because of the Translator’s code completion capabilities this makes for a very convenient library structure to use since you can type p1 and you’ll get something like this: If the user then types a few letters so that the Translator’s deep auto-completion kicks in you’ll start to see how convenient this structure is for the person implementing the interface: From there doing a the down arrow and return completes the full path to the function. It makes for an extremely pleasant work flow.

Leave A Comment?