I have a dilemma in mind that I can't solve. Should I pass object in method parameter or in parent constructor in this case ?
First idea:
public class TempChannelsPlugin extends JolssyPlugin {
private JDA client;
private TempChannelsListener listener;
private JdaCommandManager jdaCommandManager;
@Inject
public TempChannelsPlugin(JDA client, JdaCommandManager jdaCommandManager, TempChannelsListener listener) {
super(Category.UTILITIES, "Temporary Channels");
this.client = client;
this.jdaCommandManager = jdaCommandManager;
this.listener = listener;
}
@Override
protected void setup() {
this.registerListener(this.client, this.listener);
}
}
And in JolssyPlugin:
protected void registerListener(JDA client, ListenerAdapter listenerAdapter) {
this.registerListeners(client, listenerAdapter);
}
Second idea:
public class TempChannelsPlugin extends JolssyPlugin {
private JDA client;
private TempChannelsListener listener;
private JdaCommandManager jdaCommandManager;
@Inject
public TempChannelsPlugin(JDA client, JdaCommandManager jdaCommandManager, TempChannelsListener listener) {
super(client, Category.UTILITIES, "Temporary Channels");
this.jdaCommandManager = jdaCommandManager;
this.listener = listener;
}
@Override
protected void setup() {
this.registerListener(this.listener);
}
}
And in JolssyPlugin:
protected void registerListener(ListenerAdapter listenerAdapter) {
this.registerListeners(this.client, listenerAdapter);
}
What is the difference between these two cases? And why should I favor one case over another?
Notice that I'm using Guice for DI