Spring: DTO and service layer -


i'm using current layer topology:

1) dao 2) service 3) controllers(presentation)

in 1 of controllers i'm receiving following call (from clients):

public playerstatisticsdto getplayerstatistics(int playerid); 

the controller should delegate call service layer.

problem is, if create method like:

public playerstatisticsdto getplayerstatistics(int playerid); 

in service i'm making service layer aware of dto object!

i believe bad practice (or not?)

so other alternative came creating new class:

public class playerstatistics {...} 

and calling in controller:

 playerstatistics stats = this.service.getplayerstatistics(playerid);  return todto(stats); 

the problem solution dont have use class @ in project seems unnecessary duplicated code

if there 1 on 1 mapping between data requested , being presented, using dto object in presentation layer not bad practice. if change presentation layer @ later stage, can create new pojo containing presentation attribute , map them in service layer.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -