8
lorentz
5y

Do I go to object-oriented hell?
Edit: sc and cc are now unset in Connect

Comments
  • 4
    What?

    ...yes. This sucks.

    Difficult to test, even more difficult to change/replace.

    Side effects in your "setters". Someone's going to be confused at some point.

    Why don't you pass in both things you need if it can't work without both?

    Looks like c#. Why not use null propogation?
  • 2
    @spongessuck This is a Unity script. Unity loads game objects in an unknown order, hence they both call their respective 'setter' on themselves in their constructor. I don't see how null propagation could be used here. You're right about the misleading names, I'll have to come up with a scheme that implies setting up connections, Eg. "Connector.ShipToCamera"
  • 1
    @bigus-dickus Sadly C# only supports DI as a component of ASP.net and Unity doesn't have anything like that as far as I know.
  • 0
    have seen worse stuff in unity.
    this stuff can get messy sometimes
  • 0
    Who wrote that? Send him/her back! Now!!
Add Comment