Skip to content
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

Suggestion for dependency injection #100

Closed
richardsorensson opened this issue Aug 30, 2016 · 3 comments
Closed

Suggestion for dependency injection #100

richardsorensson opened this issue Aug 30, 2016 · 3 comments

Comments

@richardsorensson
Copy link

Hi,

Thought about some minor feedback regarding DI, instead of doing this on the fly to a static JobManager.

JobManager.JobFactory = new StructureMapJobFactory();
JobManager.Initialize(new MyRegistry());

Couldn't the dependency injector handle how the JobManager is instanced and from a ctor one would then just have a param of IJobManager.

I've also got a suggestion for the .Start() and .Stop(), as of now it seems as Start() is actually triggered when you call Initialize(). I'd be good if start wasn't triggered in initialize when doing DI as there might be cases where you explicitly want to start it at a certain time other then when creating the instance.

An idea could be to add a "autoStart = true" default parameter for backward compatibility.

Hope any ideas could be of interest.

@tallesl
Copy link
Contributor

tallesl commented Aug 31, 2016

Hi there,

There's basically two ways to design an API. One is the opinative way, where the API demands interfaces to be implemented and very specific calls for initialization and such. The other is focusing on doing only its job and messing as little as possible with the application design.

The former is what we refer as 'framework' while the latter is what 'library' was supposed to be.

I'm pointing FluentScheduler in the opposite direction of what you pictured. While frameworks aren't inherently bad in my book, I found libraries to be much more useful overall. I'm planning to simplify even further the API. As for the DI part, I think hooking up just an Action (and getting rid of IJobFactory altogether) would be the best overall.

I'm closing the issue but feel free to comment further on it.

@tallesl tallesl closed this as completed Aug 31, 2016
@richardsorensson
Copy link
Author

What i think it boils down to, with or without an interface for JobManager is that the method intialize() or future versions of the framework doesn't auto start all jobs until start() has been called.

e.g. when registering everything through a di container today it'd force the jobs to start running right away when initializing the registry.

Thanks.

@tallesl
Copy link
Contributor

tallesl commented Sep 2, 2016

when registering everything through a di container today it'd force the jobs to start running right away when initializing the registry.

Huh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants