This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
doc:lara:tips [2022/01/15 19:47] jbispo |
doc:lara:tips [2022/01/15 20:20] (current) jbispo |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== LARA General Tips ====== | ====== LARA General Tips ====== | ||
+ | ===== Naming Conventions ===== | ||
- | ==== Regular Expressions ==== | + | General Javascript styling guides apply, such as: |
+ | * Variable names and functions use camelCase with the first letter in lowercase | ||
+ | * Class names should be nouns, in use CamelCase with the first letter of each internal word capitalized | ||
+ | * Global variables use ALLCAPS | ||
+ | * Private functions/ | ||
+ | |||
+ | LARA-specific constructs have the following rules: | ||
+ | * Aspect names follow the same rules of Classes | ||
+ | * Join point attributes and actions follow the same rules as variable names and functions | ||
+ | |||
+ | |||
+ | /* Furthermore, | ||
+ | |||
+ | We highly recommend that LARA/JS scripts declare a single global variable or class with the same name as the script (e.g., file Query.js/ | ||
+ | |||
+ | |||
+ | ===== Regular Expressions | ||
Lara supports JavaScript regular expressions, | Lara supports JavaScript regular expressions, | ||
Line 37: | Line 54: | ||
</ | </ | ||
- | ==== Importing LARA Files ==== | + | ===== Importing LARA Files ===== |
LARA supports importing LARA files (with extension .lara) that are present in the include path (flag -i) using the keyword **import**. To import a file, you have to use the path to the file from the include folder, using ' | LARA supports importing LARA files (with extension .lara) that are present in the include path (flag -i) using the keyword **import**. To import a file, you have to use the path to the file from the include folder, using ' | ||
Line 49: | Line 66: | ||
Import statements must be the first statements in a LARA file. LARA weavers come bundled with support for a set of imports, which are part of their API (e.g., [[http:// | Import statements must be the first statements in a LARA file. LARA weavers come bundled with support for a set of imports, which are part of their API (e.g., [[http:// | ||
- | ==== Importing JS Files ==== | + | ===== Importing JS Files ===== |
- | All JS files (with extension .js) that are present in folders of the include path are automatically evaluated before any LARA file. However, there is a mechanism for importing specific JS files at the same time as LARA files. | + | JS files that are present in an include path can be imported using the LARA keyword **import**. The same rules of importing of LARA files apply. For instance, if you add as include the folder ~/src-js and you want to import the file ~/src-js/ |
- | + | ||
- | When the name of a folder of the include path ends with ' | + | |
<code lara> | <code lara> | ||
Line 66: | Line 81: | ||
Furthermore, | Furthermore, | ||
- | Since LARA is based on an older version of JS (i.e. EcmaScript 5), many recent JavaScript features are not available in LARA code. We recommend using JS files in order to have access to more recent features of JavaScript. Currently the LARA framework supports EcmaScript 2021 for JS files. | + | Since LARA scripts are based on an older version of JS (i.e. EcmaScript 5), many recent JavaScript features are not available in LARA code. We recommend using JS files in order to have access to more recent features of JavaScript. |
- | ==== Reading/ | + | |
+ | /* Currently the LARA framework supports EcmaScript 2021 for JS files. | ||
+ | ===== Reading/ | ||
LARA supports reading from and writing to JSON objects with the object **Io**: | LARA supports reading from and writing to JSON objects with the object **Io**: | ||
Line 82: | Line 99: | ||
- | ==== Testing the type of a join point ==== | + | ===== Testing the type of a join point ===== |
All join points have the attribute '' | All join points have the attribute '' | ||
This respects the join point hierarchy (e.g., " | This respects the join point hierarchy (e.g., " |