ariana-salese / DNT-TakeAwayNow

2 stars 0 forks source link

No tienen que hacer new de los services, los services se deberian inyectar solitos #28

Open maurociancio opened 1 year ago

maurociancio commented 1 year ago

https://github.com/ariana-salese/DNT-TakeAwayNow/blob/50468340cb88f9c11e1bbab68f1c76d8d39c99fc/grails-app/controllers/takeawaynow/ClienteController.groovy#L5

dos opciones a) con interface interface Service {} class ServiceImpl implements Service {...}

inyeccion automatica en el controlador

class Controller { Service service // no hacer new del service }

b) sin interface class Service {...}

inyeccion automatica en controlador class Controller { def service // sin hacer new del service }

recomiendo la opcion a ya que evitás el def.