1

I am being working with both Grails and Spring enterprise applications, I know the importance of Program for interface, but I seen most of Grails application are not following this mentioned design, rather their programming flow would be like controller -> service in the service layer they handle all the business and DB oriented things.

But when the same developer's programming style in Spring is emphasizing the importance of Program for interface

Why Grails don't following such design patterns, any reason?

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
  • 1
    since the backbone of grails is the spring framework (and what follows), so you can as well follow this paradigm in grails if you like. the framework does not prevent you from doing so. i just wanted to make this clear, that this choice is not taken away from you by choosing grails. – cfrick Mar 29 '15 at 11:10
  • @cfrick But when you see normal grails documentation, they too not following the pattern, for example, in grails.org only you can see multiple example where the services implementation are autowired directly in controller layer – Suganthan Madhavan Pillai Mar 29 '15 at 11:18
  • 1
    i could argue, that so does even springboot (https://github.com/spring-projects/spring-boot/blob/master/spring-boot-samples/spring-boot-sample-simple/src/main/java/sample/simple/service/HelloWorldService.java). so keeping docs/examples simple is not a bad thing. not enforcing a paradigm in a framework is another. – cfrick Mar 29 '15 at 11:37

1 Answers1

1

By Program for interface I presume you mean program to an interface. This is a good practice whenever crossing a boundary that is significant to your design. The art is in deciding what is significant.

Using a framework does not force you into a particular pattern or architecture. The framework does change what is convenient. Some people get lured in by that convenience and lean heavily on the framework everywhere they can. Others rebel against this and think of it as lazy coding. In the end it's a trade off.

There has actually been considerable debate on this. I have previously summed that up here

Community
  • 1
  • 1
candied_orange
  • 7,036
  • 2
  • 28
  • 62