Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Document DI Strategy #3396

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions develop-docs/DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,20 @@ thread because scheduling the init synchronously on the main thread could lead t
Related links:

- https://github.com/getsentry/sentry-cocoa/pull/3291


## Dependency Injection Strategy

Date: November 10th 2023
Contributors: @philipphofmann, @armcknight

Internal classes should ask for all dependencies via their constructor to improve testability.
Public classes should use constructor only asking for a minimal set of public classes and use the
`SentryDependencyContainer`` for resolving internal dependencies. They can and should use an
internal constructor asking for all dependencies like internal classes to improve testability.
A good example of a public class is [SentryClient](https://github.com/getsentry/sentry-cocoa/blob/e89dc54f3fd0c7ad010d9a6c7cb02ac178f3fc33/Sources/Sentry/Public/SentryClient.h#L15-L20),
and for an internal one [SentryTransport](https://github.com/getsentry/sentry-cocoa/blob/e89dc54f3fd0c7ad010d9a6c7cb02ac178f3fc33/Sources/Sentry/include/SentryHttpTransport.h).

Related links:

- [GH PR discussion](https://github.com/getsentry/sentry-cocoa/pull/3246#discussion_r1385134001)