Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • What if LateUpdate has arguements i'm not sure of the syntax in that case? Some times it passes a delta time for example LateUpdate(Timer deltaTime); Commented Jul 10, 2018 at 4:51
  • the extension method cant do everything a method could do Commented Jul 10, 2018 at 6:40
  • OP said that "not all objects follows", which is his counterpoint to a base class, but an extension method would automatically apply to everything IFollow. Not exactly an improvement over a base class implementation. The "pass-through" suggestion is also questionable. If you put it in the interface, you'll be forced to implement it in every class, or use a base class anyway, and it will also cause you some confusion (now you have multiple methods matching the IFollow.LateUpdate() call, even if only the proper class method will ever be called). Commented Jul 10, 2018 at 7:02
  • @BgrWorker I interpret the requirement as "allow a series of classes to expose IFollow without requiring duplicate implementation of LastUpdate()" which I believe this answer achieves. I wouldn't recommend adopting this as a common pattern, but maybe in a corner case it can help. The pass-through suggestion helps when the implementation is non-trivial or if there are several classes that expose IFollow and keeping their code in sync would be a chore.. Commented Jul 10, 2018 at 7:29