-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ahead-of-time runtime configuration validation #50
Comments
👍 Sent From A Very Small Keyboard
|
Sounds like a good idea and a thoughtful approach. On Sun, Jan 24, 2016 at 7:42 PM, Tim Jarratt [email protected]
|
This is both an RFC as well as a "todo" reminder for myself, or another enterprising contributor.
Objective-C's dynamic nature and the way Blindside interacts with it means that only a limited amount of compile-time checking can be performed on an injector's configuration and classes' dependency declarations. Additionally, runtime validity checking is performed on a just-in-time basis, resulting in the possibility of unexpected exceptions lurking behind every call to ``getInstance:`. I would propose providing opt-in ahead-of-time validity checking, available at the time of injector instantiation, after module configuration has been performed.
I imagine these checks could be run as part of an integration test suite, or even upon standard app launches for debug builds.
I've thought of the following possible checks so far:
BSInitializer
declarations refer to an available initializer method (see-[BSInitializer validate]
BSInitializer
argument keys actually exist (a key can be considered to exist if it either a) is explicitly bound in the injector, or b) is a class which Blindside can construct without binding.)BSPropertySet
declarations refer to usable properties on the class (see-[BSProperty determineReturnType]
)BSPropertySet
bindings refer to keys which actually existI would suggest that the entry point for these checks be a new method introduced on the
Blindside
factory class which expands upon the existing methods, adding one or more extra parameters for opting into the configuration validity checking. Using a bit mask option set or a parameter object could be a good way to allow future extensions to this feature without requiring breaking API changes.The text was updated successfully, but these errors were encountered: