Project

General

Profile

Coding Guideline » History » Version 16

Carsten Rose, 19.11.2022 14:59

1 14 Carsten Rose
{{>toc}}
2 13 Carsten Rose
3 1 Carsten Rose
h1. Coding Guideline
4
5 6 Carsten Rose
h2. QFQ General
6 1 Carsten Rose
7 6 Carsten Rose
* http://docs.qfq.io/en/master/CodingGuideline.html
8
9
h2. I-MATH
10 1 Carsten Rose
11 11 Carsten Rose
h3. Tabelle
12 1 Carsten Rose
13 11 Carsten Rose
* *Name*: Camel case, erster Buchstabe *gross*, kein Underscore. Bsp: @FormElement@
14
* Im ERD sollte bei jeder Tabelle auch die zu verwendende Abkürzung genannt werden. Bsp: @FormElement - fe@
15
* Sind in
16 1 Carsten Rose
17 12 Carsten Rose
h4. Spalten
18 1 Carsten Rose
19 11 Carsten Rose
* *Name*: Camel case, erster Buchstabe *klein*, kein Underscore. Bsp: @formId@
20
* *Erste Spalte*: @id@, Primary Key.
21
* *Vorletzte Spalte*: @created@, datetime, default: current timestamp
22
* *Letzte Spalte*: @modified@, datetime, default: current timestamp, on update current timestamp
23
* Wird auf einen Primary Key einer anderen Tabelle verwiesen, ergibt sich der Name aus <Kuerzel><Id>. Bsp: @pId@. 
24 1 Carsten Rose
25 11 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_ .
26 1 Carsten Rose
27 12 Carsten Rose
h4. Spalte 'reference'
28
29
* *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@
30
31 1 Carsten Rose
h3. Formular
32 11 Carsten Rose
33 3 Carsten Rose
* *Name*: Camel case, erster Buchstabe *klein*, kein Underscore. Bsp: @formElement@
34 11 Carsten Rose
* Sind in einer Instanz mehrere Tools, sollten die Forms anhand eines Prefixes unterschieden werden. Bsp: @dissReview@, @maReview@.
35 16 Carsten Rose
* Mandatory SIP parameter should to be mentioned in @Form.requiredNew@ and/or @Form.requiredEdit@.
36
* If the title of a FormElement isn’t descriptive enough, use _tooltip_ , note or _extraButtonInfo_ to explain to a user.
37
* Every Form should show a descriptive title to identify the task and current record. E.g. *Not* ‘Person’ *but* ‘Person: John Doe’.
38
* Often the length of a pill title if not sufficient, use a tooltip to give a more descriptive hint.
39 7 Carsten Rose
40 11 Carsten Rose
h3. Schemata
41 7 Carsten Rose
42 11 Carsten Rose
* BPMN: Zeichnung via DrawIO
43
* ERD: Zeichnung via DrawIO
44 1 Carsten Rose
45 11 Carsten Rose
h3. Constants
46 6 Carsten Rose
47 11 Carsten Rose
* Define constants in @Extensions > QFQ > Custom > ...@
48
* Dynamic values under @Extensions > QFQ > Dynamic > ...@
49 6 Carsten Rose
50 11 Carsten Rose
h3. QFQ content record
51 6 Carsten Rose
52 11 Carsten Rose
* Name the record in the header field with:
53 6 Carsten Rose
54 11 Carsten Rose
  * Regular content: [QFQ] ...
55
  * Content in the left column: [QFQ,L] ...
56
  * Content in englisch: [QFQ,E] ...
57 6 Carsten Rose
58 11 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>
59 6 Carsten Rose
#
60 1 Carsten Rose
# Shows list of Persons living in {{country:SE}}
61
#
62 6 Carsten Rose
# {{country:SE}}
63
#
64 1 Carsten Rose
</pre>
65
66 11 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>
67 6 Carsten Rose
10 {
68 1 Carsten Rose
  # Normalize variables
69 8 Carsten Rose
  sql = SELECT '{{country:SE}}' AS _country
70 6 Carsten Rose
71 8 Carsten Rose
  # List selected persons per country
72
  20.sql = SELECT p.name FROM Person AS p WHERE p.country LIKE '{{country:R}}'
73 1 Carsten Rose
}
74 8 Carsten Rose
</pre>
75
76 11 Carsten Rose
* Always comment the queries like shown above.
77
* 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>
78 1 Carsten Rose
10 {
79
  # All persons
80 9 Carsten Rose
  sql = SELECT p.name
81 8 Carsten Rose
               , GROUP_CONCAT(adr.email)
82
          FROM Person AS p
83
          LEFT JOIN address AS adr
84
            ON adr.pId=p.id
85
              AND adr.type='email'
86
          WHERE p.type='employee
87
            AND CURDATE() < p.end
88
          GROUP BY adr.pId
89
  20 {
90
    sql = SELECT ...
91
  }
92 10 Carsten Rose
}
93
</pre>
94
95 11 Carsten Rose
* Multi Use Records: If identical QFQ records used multiple times in an installation, use tt-content type 'insert records' to do the definition once, and than link all places.
96
* Multi Language: best is to define all languages on one tt-content record and the use tt-contetn type 'insert records' to link from different languages.