0

I'm starting a new project and to some extent are having trouble arguing for plays flat architecture (controllers and model - no service layer and no daos) and the heavy use of static within controllers.

To some extent it is the movement away from standard enterprise patterns proposed/adopted by DDD and fowler. While appreciating the need for a quality architecture I find the lack of 'layers' refreshing.

I've seen Guillaume's answer to the use of 'static' - [http://stackoverflow.com/a/5193721/501769] But he does not address the use of DI to enable easy unit testing. I would be interested in hearing some opinions here.

sbarlster
  • 68
  • 7

2 Answers2

1

I use service layers and daos in my play 2 application. You can use Guice or any other DIC to inject these dependencies into your controllers. What also bothers me is the static usage of the DB or Cache components. Sure you can overwrite these components during testing or you can wrap the components into a separate layer, but this is always boilerplate code.

Can you provide me a link to Guillaume's answer to the use of 'static'.

akkie
  • 2,453
  • 1
  • 18
  • 32
  • This is probably the referenced post by Guillaume: http://stackoverflow.com/a/5193721/77409 – James Ward Mar 19 '13 at 11:09
  • http://stackoverflow.com/a/5193721/501769 thanks James I think eve linked to the same item – sbarlster Mar 19 '13 at 11:15
  • Some of the friction I've encountered is specifically the ability to inject a mock dao during testing. So that 'real' database is not hit. – sbarlster Mar 19 '13 at 11:23
0

Play 2.1 added the ability to use injected controllers. For an example Spring + Play app, check out: https://github.com/jamesward/play2bars/tree/java-spring

James Ward
  • 28,966
  • 9
  • 47
  • 79