@@ -32,10 +32,32 @@ We have a few Apex specials that are described in this document.
32
32
33
33
## Architecture
34
34
35
+ The direction of dependencies go always from outside in:
36
+
37
+ ![ Architecture] ( architecture.jpg )
38
+
39
+ 1 . API's, Controllers, Infrastructure (repositories for example), or crosscurring concerns
40
+ 2 . Domain interactors
41
+ 3 . Domain entities
42
+
43
+ Reference: [ The Clean Architecture
44
+ ] ( https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html )
45
+
46
+ Quote:
47
+ > So what does the architecture of your application scream? When you look at the top level directory structure, and the source files in the highest level package; do they scream: Health Care System, or Accounting System, or Inventory Management System? Or do they scream: Rails, or Spring/Hibernate, or ASP?
48
+
49
+ Reference: [ Screaming Architecture
50
+ ] ( https://8thlight.com/blog/uncle-bob/2011/09/30/Screaming-Architecture.html )
51
+
35
52
36
53
## Quality
37
54
38
55
56
+
57
+ Reference: [ Simple, correct, fast: in that order
58
+ ] ( https://drewdevault.com/2018/07/09/Simple-correct-fast.html )
59
+
60
+
39
61
### Triggers
40
62
Because Salesforce does not enforce any particiary order in which triggers are executed, only write one trigger per SObject.
41
63
That way you are in control of the order in which things are executed.
@@ -71,13 +93,21 @@ kept out of the trigger and be put in domain classes.
71
93
72
94
## Principles
73
95
96
+ In order to make clean code, use the following principles of SOLID:
97
+ - SRP: Single Responsibility Principal
98
+ - OCP: Open/Close Principal
99
+ - LSP: Liscov Substitution Principal
100
+ - ISP: Interface Segregation Principle
101
+ - DIP: Dependency Inversion Principle
74
102
75
103
### Use of repositories
76
104
105
+ Repositories are samples of implementing the Dependency Inversion Principle.
106
+
77
107
The use of repositories is a must in order to execute SOQL queries or DML statements. So all interactions with the
78
108
database will be done in these repositories and not directly in business logic classes.
79
109
80
- In addition, the unit test classes will use fake mock repositories instead, so the use of interfaces for this
110
+ In addition, the unit test classes will use fake mock repositories instead, so the use of interfaces for
81
111
repositories is also required.
82
112
83
113
0 commit comments