This question concerns design issues for a Spring service class.
I have a Service class that has 50+ @Inject - able components and is of the form:
@Service
public class ServiceClass implements IServiceClass{
@Inject private RepositoryA repoA;
@Inject private RepositoryB repoB;
[... 20+ of these ]
@Inject private ConverterA converterA;
@Inject private ConverterB converterB;
[...20+ more of these ]
}
I understand this might look like code smell but the reality is this is how I inherited this piece of code.
My concerns are:
a. The class looks horrendous with 50+ @Inject properties. Can I leverage any design pattern to look up JPA repositories instead of explicitly injecting them in the service class?
b. Most of the converters are of the form :
@Component
public class ConverterA{
public List<SomeDTO> convert(final List<SomeEntity> entityList){
//iterate over entities and call the convert method for each
}
public SomeDTO convert( SomeEntity someEntity ){
// use Dozer to convert
}
}
but some of them have custom conversion logic.
Is there a better way to design these converters?
Any help or even mentioning the design patterns I should look into would be extremely beneficial.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire