InputManager: update member signatures to be static
See original GitHub issueSeeing as the InputManager
is a singleton it makes sense that the members could/should be static.
Pros:
InputManager.Method();
VSInputManager.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:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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).