Skip to content

Commit

Permalink
Merge branch 'master' of github.com:hadashiA/VContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
hadashiA committed Jul 2, 2020
2 parents c8f6ed4 + c857b3a commit 72b5cf2
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,19 @@ Following is a deep profiler Unity result sample.
## What is DI ?

DI (Dependency Injection) is a general technique in OOP that all about removing uninteresting dependencies from your code.
It brings testability, maintainability, extensibility or any kind of exchangeability to your object graph.
It brings testability, maintainability, extensibility or any kind of exchangeability to your object graph.

In all programming paradigms, the basic design is, weak module coupling and strong module cohesion.

How does OOP do this?

As you know, OOP(Object Oriented Programming) does it through objects.
1. Objects hides the details of its responsibility (encapsulation).
2. Objects transfer work outside their responsibilities to other objects

Actually, There is a problem in doing this fundamentally.
If you write the delegation object in the class code, it means tight coupling at the source code level.
The only way to exclude a non-interesting dependency from a class is to pass from outside.

The only way to exclude a non-interesting dependency from a source file is to pass the dependency from outside.

So who passes the dependency?
If your class receives dependencies externally, need help from outside.

DI, is a technique that facilitates a place to resolve dependencies completely outside.
Then, if your class receives dependencies externally, need help from outside.
DI is a technique that facilitates a place to resolve dependencies completely outside.

Terminology:
- Composition Root : The place where you make settings to resolve dependencies.
Expand Down Expand Up @@ -138,8 +132,7 @@ namespace MyGame
```

Note:
VContainer always required a `Lifetime` argument explicitly.
This gives us transparency and consistency.
- VContainer always required a `Lifetime` argument explicitly. This gives us transparency and consistency.

**3. Create LifetimeScope**

Expand Down Expand Up @@ -635,11 +628,10 @@ it has following behaviours:
- For `LifeTime.Transient`
- Instance creating for each resolving.
- If parent and child have the same type, child will prioritize itself.
- Instance will be different for each child.
- For `Lifetime.Scoped`:
- If same child, returns same instance.
- If parent and child have the same type, child will prioritize itself.
- Instance will be different for each child.
- If same child, returns same instance.
- If parent and child have the same type, child will prioritize itself.
- When a `LifetimeScope` is destroyed, objects with `IDisposable` implemented are called `Dispose()`.

:warning: If scene is alive and only `LifetimeScope` is destroyed, MonoBehaviour registered as `Lifetime.Scoped` is not automatically destroyed.
Expand Down

0 comments on commit 72b5cf2

Please sign in to comment.