Skip to content

Commit 66c83d8

Browse files
committed
Architecture
1 parent 1626fb1 commit 66c83d8

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

architecture.jpg

1.21 MB
Loading

readme.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,32 @@ We have a few Apex specials that are described in this document.
3232

3333
## Architecture
3434

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+
3552

3653
## Quality
3754

3855

56+
57+
Reference: [Simple, correct, fast: in that order
58+
](https://drewdevault.com/2018/07/09/Simple-correct-fast.html)
59+
60+
3961
### Triggers
4062
Because Salesforce does not enforce any particiary order in which triggers are executed, only write one trigger per SObject.
4163
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.
7193

7294
## Principles
7395

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
74102

75103
### Use of repositories
76104

105+
Repositories are samples of implementing the Dependency Inversion Principle.
106+
77107
The use of repositories is a must in order to execute SOQL queries or DML statements. So all interactions with the
78108
database will be done in these repositories and not directly in business logic classes.
79109

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
81111
repositories is also required.
82112

83113

0 commit comments

Comments
 (0)