Zenject: 소개

yoonsang lee·2022년 5월 29일
0

zenejct

목록 보기
1/1

Zenject?

repository location: https://github.com/modesttree/Zenject

A Dependency-Injection Library for unity.

WebGL support
Ill2cpp support


Background

DI usage in Unity, hasn't developped since its beginning. for instance, drag the instance and drop in its target object, Singleton / Static, Scriptable Object makes hard to maintain an application.


Dependency Injection?

Bind the instance to the target object. A form of Inversion Of Control (IOC), it principally aims to Separate the concenrs and it is required for loosely-coupled instruction.

basically any form of receiving dependency meets the DI condition. for instance, passing parameters to the method of the object.


Pros & Cons of DI

Pros

  1. It decreases coupling between all classes
    the class goes more reusable, testable and maintainable.

  2. It also reduces boilerplate codes, since all dependency creation is handled by a single component.

  3. It allows concurrent development between developers. since the creation happens only in the one component, classes do not need to be concerned of confliction

  4. DI benefits are also relevant to unit-testing. the system does not require to recompile.

Cons

  1. Requires the developer to implement the creation code. it is prone to make errors and some boilerplates.

  2. Make code diffcult to trace as it separates behaviour from construction.


Motivation

As DI code has bothersome and no standard in Unity, Zenject can automate this process at ease.

Zenject pushes the responsibility of deciding which specific implementations of which class to use further and further up in the object graph.

and it is samely called as the entry point or composition root, at which point all dependencies must be satisfied before things start.

profile
Unity3D Freelancer Programmer + React

0개의 댓글