...
The use of an IoC container will foster a more declarative approach to building user interfaces, allowing developers to wire up behaviour and declare bindings in a way that can be overridden by the user or implementor. Key to this is offloading certain programmatic logic to the framework that is most susceptible to the risk of hardcoding. For example, keyboard handlers:
These examples are still half-baked, Sunday night musings...
Typical barebones JavaScript approach:
Code Block |
---|
Fluid declarative approachFramework-managed key bindings:
Code Block |
---|
var keymap = { modifier: CTRL, key: LEFT-ARROWC }; $ (element).bindActionToKey ("CutCopy", keymap, cutFunction); |
Declarative dependency injection:
Code Block |
---|
beans {
textEditorComponent: {
bindings: {
keyMaps: windows
}
}
windows: {
Copy: {
modifier: CTRL,
key: C
}
}
mac: {
Copy: {
modifier: Command,
key: C
}
}
}
|