Coding Guideline » History » Version 10
Carsten Rose, 06.11.2022 18:36
1 | 1 | Carsten Rose | h1. Coding Guideline |
---|---|---|---|
2 | |||
3 | |||
4 | 6 | Carsten Rose | h2. QFQ General |
5 | 1 | Carsten Rose | |
6 | 6 | Carsten Rose | * http://docs.qfq.io/en/master/CodingGuideline.html |
7 | |||
8 | h2. I-MATH |
||
9 | |||
10 | 7 | Carsten Rose | * Tabelle: |
11 | 1 | Carsten Rose | |
12 | 7 | Carsten Rose | * *Name*: Camel case, erster Buchstabe *gross*, kein Underscore. Bsp: @FormElement@ |
13 | * Im ERD sollte bei jeder Tabelle auch die zu verwendende Abkürzung genannt werden. Bsp: @FormElement - fe@ |
||
14 | * Sind in |
||
15 | 1 | Carsten Rose | |
16 | 7 | Carsten Rose | * Spalten: |
17 | 1 | Carsten Rose | |
18 | 7 | Carsten Rose | * *Name*: Camel case, erster Buchstabe *klein*, kein Underscore. Bsp: @formId@ |
19 | * *Erste Spalte*: @id@, Primary Key. |
||
20 | * *Vorletzte Spalte*: @created@, datetime, default: current timestamp |
||
21 | * *Letzte Spalte*: @modified@, datetime, default: current timestamp, on update current timestamp |
||
22 | * Wird auf einen Primary Key einer anderen Tabelle verwiesen, ergibt sich der Name aus <Kuerzel><Id>. Bsp: @pId@. |
||
23 | 1 | Carsten Rose | |
24 | 7 | Carsten Rose | * Gibt es in einer Tabelle a) mehrere Spalten auf die gleiche Fremdtabelle (und muessen daher unterschiedlich sein) oder b) soll der Spaltenamen klarer beschreiben, kann eine Spezifizierung angehängt werden. Bsp: @pIdApplicant@, @pIdHead@. _Auf jeden Fall steht das @pId@ am Anfang_ . |
25 | 1 | Carsten Rose | |
26 | 7 | Carsten Rose | * Formular |
27 | 1 | Carsten Rose | |
28 | 7 | Carsten Rose | * *Name*: Camel case, erster Buchstabe *klein*, kein Underscore. Bsp: @formElement@ |
29 | * Sind in einer Instanz mehrere Tools, sollten die Forms anhand eines Prefixes unterschieden werden. Bsp: @dissReview@, @maReview@. |
||
30 | 1 | Carsten Rose | |
31 | 7 | Carsten Rose | * Spalte 'reference' |
32 | 1 | Carsten Rose | |
33 | 7 | Carsten Rose | * *Name*: Als Vorbereitung um unterschiedliche Tools aus verschiedenen Instanzen mergen zu koennen, wird empfohlen die Referenz Records mit einem eindeutigen Prefix zu versehen. Bsp: @my_exercise_group@ |
34 | 3 | Carsten Rose | |
35 | 7 | Carsten Rose | * BPMN |
36 | 3 | Carsten Rose | |
37 | 7 | Carsten Rose | * Zeichnung via DrawIO |
38 | 3 | Carsten Rose | |
39 | 7 | Carsten Rose | * ERD |
40 | 1 | Carsten Rose | |
41 | 7 | Carsten Rose | * Zeichnung via DrawIO |
42 | 6 | Carsten Rose | |
43 | 7 | Carsten Rose | * Constants |
44 | 6 | Carsten Rose | |
45 | 7 | Carsten Rose | * Define constants in @Extensions > QFQ > Custom > ...@ |
46 | * Dynamic values under @Extensions > QFQ > Dynamic > ...@ |
||
47 | 6 | Carsten Rose | |
48 | 7 | Carsten Rose | * QFQ content record |
49 | 6 | Carsten Rose | |
50 | 7 | Carsten Rose | * Name the record in the header field with: |
51 | 6 | Carsten Rose | |
52 | 7 | Carsten Rose | * Regular content: [QFQ] ... |
53 | * Content in the left column: [QFQ,L] ... |
||
54 | * Content in englisch: [QFQ,E] ... |
||
55 | 6 | Carsten Rose | |
56 | 8 | Carsten Rose | * The first lines should be comments, explaining what the record does and list *all* passed variables (STORE_SIP, STORE_USER). Optional variables are indicated by using STORE_EMPTY or STORE_ZERO: <pre> |
57 | 6 | Carsten Rose | # |
58 | # Shows list of Persons living in {{country:SE}} |
||
59 | # |
||
60 | # {{country:SE}} |
||
61 | # |
||
62 | </pre> |
||
63 | 1 | Carsten Rose | |
64 | 8 | Carsten Rose | * Normalize variables: A good practice is to define all possible STORE_SIP Parameter in a SQL at the beginning and copy them to STORE_RECORD: <pre> |
65 | 6 | Carsten Rose | 10 { |
66 | 8 | Carsten Rose | # Normalize variables |
67 | sql = SELECT '{{country:SE}}' AS _country |
||
68 | 1 | Carsten Rose | |
69 | 8 | Carsten Rose | # List selected persons per country |
70 | 20.sql = SELECT p.name FROM Person AS p WHERE p.country LIKE '{{country:R}}' |
||
71 | 1 | Carsten Rose | } |
72 | </pre> |
||
73 | |||
74 | * Always comment the queries like shown above. |
||
75 | 9 | Carsten Rose | * Indention are two spaces and reflect child parent relation. Example: A _WHERE_ clause is a child of a _SELECT_ , an _AND_ statement is a child of a _SELECT_ or _LEFT JOIN ... ON ..._. <pre> |
76 | 8 | Carsten Rose | 10 { |
77 | # All persons |
||
78 | sql = SELECT p.name |
||
79 | , GROUP_CONCAT(adr.email) |
||
80 | FROM Person AS p |
||
81 | LEFT JOIN address AS adr |
||
82 | ON adr.pId=p.id |
||
83 | AND adr.type='email' |
||
84 | WHERE p.type='employee |
||
85 | AND CURDATE() < p.end |
||
86 | GROUP BY adr.pId |
||
87 | 10 | Carsten Rose | 20 { |
88 | sql = SELECT ... |
||
89 | } |
||
90 | 8 | Carsten Rose | } |
91 | </pre> |
||
92 | |||
93 | 6 | Carsten Rose | |
94 | 7 | Carsten Rose | * QFQ Form |
95 | 6 | Carsten Rose | |
96 | 7 | Carsten Rose | * Mandatory SIP parameter should to be mentioned in Form.requiredNew and/or Form.requiredEdit. |
97 | * If the title of a FormElement isn’t descriptive enough, use tooltip, note or extraButtonInfo to explain to a user. |
||
98 | * Every Form should show a descriptive title to identify the task and current record. E.g. Not ‘Person’ but ‘Person: John Doe’. |
||
99 | * Often the length of a pill title if not sufficient, use a tooltip to give a more descriptive hint. |