lundi 18 juin 2018

Which of the method is more correct to call object's algorithm to execute conversion?

I have a strategy pattern with factories inside. I don't know how much architecture should be visible outside. Which of the method is more correct?

1.

converterStrategyContext.getStrategy(ProductConverterStrategy.class).convert(product, ShowProductDto.class)

2.

converterStrategyContext.getStrategy(ProductConverterStrategy.class).getFactory(ShowProductDtoFactory.class).convert(product)

3.

converterStrategyContext.convert(product, ShowProductDto.class)

Specifying fewer arguments means more operations inside methods and forces to store relational structures of strategies, factories and dto to which the object is to be converted

Aucun commentaire:

Enregistrer un commentaire