[swift-users] Feedback for Dependency Injection Framework?
Mike Lewis
mikelikespie at gmail.com
Tue Jun 14 18:55:52 CDT 2016
Hi,
I've recently open sourced a dependency injection framework for Swift
called Cleanse. https://github.com/square/cleanse
It does a couple things I'd consider novel with the type system to make
wiring up functions easy without having to use reflection or other runtime
or compile-time hacks (I tried elaborating on it in this part of the README
here
https://github.com/square/Cleanse#dependency-requesting-terminating-methods)
Anyways, I'm looking for feedback on the design and use of this library,
and maybe strike up a discussion on language features that may make writing
a library such as this be able to be "cleaner" in the future. Couple things
that come to mind are custom annotations for qualifying types (instead of
what we call "type tags"), variadic generic arguments (which we work around
by code generating the various arities), or even a plugin architecture to
achieve things similar to what can be done with Java annotation processors.
I'd also be interested in feedback on some more of the implementation
details. e.g. is using this to key objects by type a good thing or a
terrible thing?
https://github.com/square/Cleanse/blob/master/Cleanse/TypeKeyProtocol.swift
Since Swift generics don't seem to be completely understood by the general
population, was hoping I could get some concrete feedback here. Even would
be stoked with a response to the tune of "You don't need DI in Swift for
reasons X, Y, and Z."
Thanks!
Mike Lewis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160614/7990adb4/attachment.html>
More information about the swift-users
mailing list