3 ms·
> Being able to test UI behaviour is a huge difference maker. obviously UI tests are being run today so this is not really an issue, right ? > (Also even if y
by jcelerier 7y ago
> Being able to test UI behaviour is a huge difference maker.
obviously UI tests are being run today so this is not really an issue, right ?
> (Also even if you do believe that a singleton is ok in this case, it's clearly no different from a global variable).
yes, that's global state all the same
> Which is a problem in itself.
maybe, does not prevent writing a lot of very useful apps.
- lmm 7y ago> obviously UI tests are being run today so this is not really an issue, right ? UI tests are notoriously slow, flaky and generally worse than other kinds of tests. They're absolutely a significant pain point in software development today. > maybe, does not prevent writing a lot of very useful apps. People write useful code with global state. People wrote useful code with gotos, with no memory safety... that computers are useful does not mean there isn't plenty of room for improvement.
- kazinator 7y agoAvoiding singletons in the app implementation will not put a dent in UI testability. If you instantiate the MainWindow as a local variable in the top-level function, and pass that object everywhere it is required as an argument, external testing of your UI is not any easier.
- lmm 7y agoIt's a step in the right direction, and it gives some immediate value: you can see which functions don't actually need the MainWindow and can therefore be tested conventionally (you might argue that those were never actually UI tests, but in practice you'll end up using your UI testing techniques for things that don't actually use UI if you can't tell), and you're nudged towards only passing it where it's needed; also you could try to mock or stub it, which might cover at least some of the simple cases.