Comments (2)
Errors out of constructors are Exceptions 😅
Exceptions are only magic if you use them only once or twice and they come as a surprise. If you are using them throughout then they can be expected and people should code for it. As for error codes: This is what exception types are for.
If you want to avoid them at any cost, then I agree that having a separate StereoKitApp.Init() function would better mirror the C behavior:
public StereoKitApp()
{
// This would be empty now?
}
public Init(string name, Runtime runtime)
{
return sk_init(name, runtime);
}
Then I would appreciate blocking any other functionality until the initialization is done, so some kind of public bool isInitialized
for me to check.
What do you think?
from stereokit.
Something is definitely needed here! I remember writing that example and thinking, 'Huh, I can't check errors out of a constructor, can I?'. Then I moved on. There's definitely a lot of error checking I've deferred so far, it would be really nice to have a good logging system too.
I'm not a fan of catching exceptions, it falls into the realm of 'Magic! Where Did That Functionality Come From?' to me. So I generally try to avoid throwing them unless I actually intend to crash an application. I much prefer error codes!
So I think the core trouble here is that the constructor is doing a little too much work! I think my preference would be either a static StereoKitApp.Create() that can return null, or an instance member StereoKitApp.Initialize() that can return an error code. That and better logging :)
from stereokit.
Related Issues (20)
- tex_create_file_type creates a 0x0 size texture if the file doesn't exist HOT 1
- Keyboard Customization API HOT 3
- [Docs-Controller] On class Controller the text about X2 methods talk of button A or X instead of B or Y
- Hand Mesh Ext Issues HOT 6
- C# default values in stereokit_ui.h HOT 3
- World.HasBounds returns true even if xrGetReferenceSpaceBoundsRect failed
- Unable to trigger sphere_point_contains and bounds_point_contains HOT 2
- Is there a built-in way to make a window follow you? HOT 1
- Add overload to Model Ray intersection to return the relevant ModelNode
- Texture formats on Quest
- Update partial rect of `Tex`
- OriginMode strange behavior on Quest HOT 6
- Why does Stereokit not have a gesture model on Snapdragon Spaces HOT 2
- Hyphens in directory name not handled well by dotnet new HOT 2
- `Renderer.RenderTo` results in y-inverted image with Android HOT 2
- How Stereokit interacts with Unity?
- Need some way of loading a GLSL shader directly instead of converting from HLSL, or a binding in skshaderc for GLSL samplerExternalOES HOT 4
- Platform.ReadFileBytes(filename) and Assets dir HOT 4
- Unicode rendering missing character in Linux simulator HOT 2
- How to use Stereokit to develop overlay applications?How Stereokit interacts with OpenXL?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stereokit.