Do NOT follow this link or you will be banned from the site!
Templates And Automation
Submitted by thedosmann on Thu, 08/30/2012 - 13:25
Deja Vous
A coding template is a design that has replaceable or re-definable parts that when changed does not effect overall structure. In programming, and in computers generally, there are numerous duplications. There are events, checks, layouts, and other parts of computing that do not change. These parts are often put into templates that allow for differing outputs while maintaining the same general methods to accomplish the code or program execution.
One well known and practical example would be letter templates. This is when you compose a letter that is a general response or correspondence that may be sent to several different parties. The heading and perhaps footer may change but the general content remains the same so you use this template over and over without changing the content. In HTML templates one would change the content but the general markup remains the same. In this way you can use the same page markup but still totally change how the web page looks by replacing content components. These templates are sometimes referred to as 'Boilerplate' templates. Referring to using the same stove, the same pan, but changing the ingredients up a little. Look at cell phone theme builders for a great example on template efficiency. These guys take a stable build and then 'cook' their own theme on top of it.
Templates, in various forms, have been around since the first computer user started doing repetitive tasks and created macros. Actually, there are several different types of templates. Even Cron Jobs can be referred to as a type of template. In coding one might build a function that outputs a desired result or performs a certain task. That function can be reused for a completely different task by only changing a few parts of the overall code. Using a function in this way your applying templates. CSS is a huge user of templates. You can construct a CSS layout and use that layout in several sites by only changing a few code components. Imagine a program that generates 10 random geometric shapes and then gives you the task of drawing a shape that could pass thru each different shape. You would have to design it so all the turns and curves would successfully maneuver through all the differing shapes. The best way to accomplish this would be align and put together all 10 of the shapes and the resulting inward shape would be your template.
A streamlined process
Templates can be used to streamline business processes and to limit mistakes and errors in tasks that are performed repetitively. I was once asked to create a process to automate a DVD creation process. My first goal was to go through the process manually and determine what parts of the process changed in each DVD creation. Once I had isolated what changed I created a template, or in this case a few templates, that performed the repetitive processes. This was actually a location based process so all the DVD creator had to do was to click on the location template which triggered a number pf processes including program execution, proper image and sound importing, and correct location files. The end result cut production time by half and most importantly reduced user error. By reducing the steps in the DVD creation process we also decreased the possibility of user errors. An additional benefit isthat the training of another person to do the same task suddenly became less of an issue.
Using templates in coding processes works the same way. We look at what changes in the code when applying it to different scenarios. If there are few changes that are required it makes sense to develop a template for the function or process. If you find yourself entering the same code over and over it may be time to look at creating a library of templates to use for those tasks. One of the positive aspects of coding templates is often you don't have change anything inside the template. By creating the variables outside of the template to match what the code is looking for you can incorporate the template into your code like a perfectly matched puzzle piece.
A template and automation go hand-in-hand because behind every automation there is a cleverly constructed template.
by Jim Atkins "thedosmann"
Share it now!