-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNAMING.txt
93 lines (65 loc) · 3.14 KB
/
NAMING.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
--Fusion Ticket File Naming Conventions--
Please feel free to update this document if you feel it to be inacurrate or incorrect.
1. CODE NAMING
There are a hundred different ways to name class names and variables.
Everyone has their preferred methods, but for the sake of this project
we should agree that everyone should try and follow the rules below.
1.1: ClassNames: Class names should have a CAPITAL for each letter
of each word.
No spaces, no special chars and no underscores.
Good -> Order, EmailController, SwiftEmailCompiler
Bad -> order, emailController, Swift_Email_Compiler
1.2: Function names: functions should use a CamelCaps style naming,
but should follow these rules.
First word lower case, Every subsequent word has uppercase first letter,
No spaces, no special chars and no underscores.
Good -> save(), deleteOrder(), isValid(), doThisFunctionNow()
Bad -> Save(), DeleteOrder(), is_Valid(), do_this_function_now()
There may be exceptions to these rules, such as: __construct.
Or _load() which would be the private version of load().
E.g. :
static public load(){.. return self::_load()}
private _load()
1.3 Variables:
Vars should follow the same rules as functions (See above).
Exceptions:
When following table naming. So we can set $this->order_id
as this would match the column name of order_id in the order table.
Construct variables used by a abstract class:
protected _columns = array(...)
protected _id = '..'
2. File Naming
Rules:
All Lower Case
Full stop between each
Type of file post file name.
Types of Files:
Classes : class.classname.php ie. class.session.php
Models : model.modelname.php ie. model.seat.php
Simple Files : filename.php ie. init.php
Compilers : compiler.complib.comptype.php ie. compiler.swift.email.php
Ajax : ajax.ajaxname.php ie. ajax.posajax.php
Etc..
Examples:
model.order.php
compiler.swift.email.php
Respective Class Names:
class Order {..}
class EmailSwiftCompiler{..}
3. Database Naming
3.1: Tables
Table names should be sensible at best. At worst, they should be random UTF8 characters that have
no relation to the table contents. Every new table should be lowercase, this makes the system
cross compatible between Windows and Unix but is also recommended by InnoDB to reduce confusion
between lower and uppercase tables.
Table names should only include letters, numbers, and '_', and they should also be pluralised if
holding an object style records like orders.
Good : orders, order_statuses, seats
Bad : order, OrderStatus, SEATS
3.2: Column Names
Should follow there table name affixed with their name. Again sensible names, if the table name
is pluralised remove the plural. orders = order
If the table name is long or contains '_' then using an abbreviation is recommended
It is not required but hinting at the type of field can be helpful.
Good : order_id, order_timestamp, os_id (order_statuses) etc...
Bad : id, ord_id, orderid, order_statuses_id