Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 140d8b3

Browse files
committed
tech Guidelines: factories vs new keyword
1 parent e6e5485 commit 140d8b3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

guides/v2.2/coding-standards/technical-guidelines.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ Use [RFC2119] to interpret keywords like:
4949

5050
2.1. Object decomposition MUST follow the [SOLID principles].
5151

52-
2.2. Object MUST be ready for use after instantiation. No additional public initialization methods are allowed.
52+
2.2. Object instantiation
53+
54+
2.2.1. An object MUST be ready for use after instantiation. No additional public initialization methods are allowed.
5355

5456
{% collapsible Examples: %}
5557
<table>
@@ -98,6 +100,11 @@ class Config
98100
{% endcollapsible %}
99101
---
100102

103+
2.2.2. Factories SHOULD be used for object instantiation instead of `new` keyword. An object SHOULD be replaceable for testing or extensibility purposes.
104+
Exception: DTOs. There is no behavior in DTOs, so there is no reason for its replaceability.
105+
Tests can create real DTOs for stubs.
106+
Data interfaces, Exceptions and `Zend_Db_Expr` are examples of DTOs.
107+
101108
{:start="2.3"}
102109
2.3. Class constructor can have only dependency assignment operations and/or argument validation operations. No other operations are allowed.
103110

0 commit comments

Comments
 (0)