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

Commit 3f9f10c

Browse files
authored
Merge pull request #3982 from buskamuza/ok_tech-guidelines-factories
Tech Guidelines: factories vs `new` keyword
2 parents 6d18abc + 7ebca1f commit 3f9f10c

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
@@ -48,7 +48,9 @@ Use [RFC2119] to interpret keywords like:
4848

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

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

5355
{% collapsible Examples: %}
5456

@@ -93,6 +95,11 @@ class Config
9395

9496
---
9597

98+
2.2.2. Factories SHOULD be used for object instantiation instead of `new` keyword. An object SHOULD be replaceable for testing or extensibility purposes.
99+
Exception: [DTOs](https://en.wikipedia.org/wiki/Data_transfer_object). There is no behavior in DTOs, so there is no reason for its replaceability.
100+
Tests can create real DTOs for stubs.
101+
Data interfaces, Exceptions and `Zend_Db_Expr` are examples of DTOs.
102+
96103
{:start="2.3"}
97104
2.3. Class constructor can have only dependency assignment operations and/or argument validation operations. No other operations are allowed.
98105

0 commit comments

Comments
 (0)