You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A class has two constructors. One is used by tests, the other by production code.
There really should be just one constructor (or to be more precise - constructors needed by production code). Generally, its the most general one, e.g. with the most parameters: in this case its the second constructor. If the tests needs a different constructor then the test code should define a factory method that calls the constructor.
What's weird about this MessageConsumerActiveMQImpl is that the production code uses the simpler constructor: messageModes is always empty. This means one of two things:
MessageConsumerActiveMQImpl implements unused functionality and can be simplified - along with the tests
The production code is incomplete and needs to support the configuration of different ChannelTypes.
Message from Chris:
I see this pattern frequently:
public MessageConsumerActiveMQImpl(String url,
Optional user,
Optional password) {
this(url, Collections.emptyMap(), user, password);
}
public MessageConsumerActiveMQImpl(String url,
Map<String, ChannelType> messageModes,
Optional user,
Optional password) {
....
}
A class has two constructors. One is used by tests, the other by production code.
There really should be just one constructor (or to be more precise - constructors needed by production code). Generally, its the most general one, e.g. with the most parameters: in this case its the second constructor. If the tests needs a different constructor then the test code should define a factory method that calls the constructor.
What's weird about this MessageConsumerActiveMQImpl is that the production code uses the simpler constructor: messageModes is always empty. This means one of two things:
I suspect its #2
The text was updated successfully, but these errors were encountered: