question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InputManager: update member signatures to be static

See original GitHub issue

Seeing as the InputManager is a singleton it makes sense that the members could/should be static.

Pros:

  • InputManager.Method(); VS InputManager.Instance.Method();

Cons:

  • Light refactoring. People would need to remove the Instance part of their code.

What do you guys think? Is there any other pros/cons I may have looked over? This change should not affect behavior in any way.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
maxouelletcommented, Mar 13, 2017

It wouldn’t really help: it actually makes it impossible to unit test your classes without taking a dependency on a specific implementation of the static class. Static methods make sense when you use them for generic math functions or similar functions that have no complex dependencies, but that isn’t the case for InputManager.

You are right that it doesn’t make a difference for integration tests.

Eventually, I assume we will also want to add optional features to the InputManager, or have alternate implementations. When/if that happens, having static methods would prevent these scenarios.

1reaction
maxouelletcommented, Mar 7, 2017

My two cents: I don’t really like this idea. Having static methods all over the place is pretty bad for isolating components and properly unit testing code. In fact, I’ve been trying to move away from singletons as much as possible across my project’s codebase for that exact reason. Instead of using singletons, I use some dependency injection to achieve a similar purpose in a more modular and decoupled way. While that solution might be too complicated for the HoloToolkit, moving to having static classes and methods completely breaks anyone that wants to do that.

You could also imagine that someone might eventually want to inherit from InputManager and add more functionalities to it. If you make it static, that makes this scenario impossible.

If you want to avoid having to call .Instance everywhere, you can always get the instance once in your Start method and cache it. That way, it’s super simple to switch how you retrieve the input manager (if it ever moves away from being a singleton, for example).

Read more comments on GitHub >

github_iconTop Results From Across the Web

InputManager
Quickly bring your app to life with less code, using a modern declarative approach to UI, and the simplicity of Kotlin. ... Start...
Read more >
Custom Inputmanager v1.4 - VERY easy to use now
Hello Roidz, I have tested it and i have use for it. The only fault it has when i click on one of...
Read more >
services/jni/com_android_server_InputManager.cpp
// Do this after the dispatcher has updated the window handle state. bool newPointerGesturesEnabled = true;. size_t ...
Read more >
include/InputManager.h · v1.0 · Manuel Richter ... - GitLab
there will be a bigger update to our gitlab server, which requires a longer ... An error occurred while loading commit signatures ......
Read more >
Events & Delegates in Unity
Update is called every frame so, for checks that are made constantly, ... This is a delegate signature, a reference for a type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found