Easy Code Snippets (all project type)

Written by Brandon B. Stewart


Available through the Edit->Snippets menu.

Easy Code allows for the use of reusable code and comment segments called "code snippets".  Snippets are blocks of program code or programmer comments which are usually small but may vary in size, purpose, and scope, and are contained either within a standard text file (*.txt) or an extended markup language file (*.xml). Snippets generally are formatted in a template style manner so that a segment of code or comment(s) may be inserted into a target source file and require minimal postliminary changes in order for it to work as intended in each particular instance.

To retain simplicity, Easy Code uses only snippets stored in the standard text format (*.txt). The new Easy Code "Snippets" subfolder ("..\EasyCode\Snippets") is the default path to the top-level snippet directory. Using the 'Settings' dialog form however, the user may specify any alternate top-level folder in which to store snippets. The user may subsequently create any number of snippet subfolders within the top-level folder. It is ideal programming practice to limit each snippet file to only one segment of code which serves a single function, and name each snippet file according to the particular function it performs. The user should not worry about this resulting in having too many snippet files, as each snippet folder and subfolder can contain an unlimited number of snippet files. It is also ideal practice to store each snippet file in a folder of which its name directly corresponds to the grouping or type of snippet files it contains. For example: all snippet files which deal with file processing should be placed in a subfolder named something like 'File Processing'. Snippet files which add comment headers to the beginning of source files and functions should be placed in a subfolder named something similar to 'Header Comments'. Snippet files which handle peripheral input and output should be placed in a subfolder named 'Input and Output'. And so on, and so on.


 


NOTE: The 'Edit --> Snippets' menu label is statically linked to the top-level snippet folder and will always retain the name of "Snippets", regardless of what top-level snippet folder the user might choose to designate. In contrast, however, any snippet sub-menu labels will always be dynamic, and therefore, the name of each will reflect the corresponding subfolder created by the user. Additionally, any snippet menu item will always reflect the name of its corresponding file - minus the file extension (txt). Because the name of each snippet file will determine its identifier to be displayed in the Snippet menu, it is ideal practice to name each file something meaningful where it can easily be selected from the menu.

To insert a code or comment snippet: simply set the cursor at the desired location within the target source file, select Edit --> Snippets from the Easy Code menu and navigate to the correct subfolder menu label, then click the desired snippet item.

REMARKS: Two code snippets are included in the "..\EasyCode\Snippets\Header Comments" subfolder.