Search Unity

Good Coding Practices Help

Discussion in 'Scripting' started by yazsh_, Oct 5, 2014.

  1. yazsh_

    yazsh_

    Joined:
    Oct 3, 2014
    Posts:
    10
    In the good coding practices tutorial there is a section on Dependency Injection. I really didn't understand how interfaces would lessen the dependency of playerinput to playerphysics. It seemed like a lot of extra code where you could just use 2 classes. This is what I interpereted her instructions to be.

    (in Unityscript)
    Class PlayerInput{

    funtion applyPhysics(IActorPhysics actor){


    }

    }
    Interface IActorPhysics {
    function move();

    }
    Class PlayerPhysics implements IActorPhysics{

    move


    }



    Here is a link to the tutorial:
    http://unity3d.com/learn/tutorials/modules/intermediate/scripting/coding-practices