3 ms·
This article reminds me of Struts2 http://en.wikipedia.org/wiki/Apache_Struts http://en.wikipedia.org/wiki/Apache_Struts MVC with "action" (or event, similar
by edwinnathaniel 14y ago
This article reminds me of Struts2
http://en.wikipedia.org/wiki/Apache_Struts http://en.wikipedia.org/wiki/Apache_Struts
MVC with "action" (or event, similar semantics).
Speaking of Java/Spring-MVC approach, I tend to have a mix approach of Service and Repository (since DAO seems to be getting a lot of bad-rep, time to pick a new name :D).
Controller -> Service (SOAP) or Resource (REST) [although Resource could simply forward to Service as well)
or
Controller -> Repository (for specific entity that requires no interaction with other entities)
Unfortunately the Service layer is necessary in the situation where there are 2 or more domain models need to interact with each other.
This seems to help writing test-automations by splitting the tests into 2 categories:
1) End-to-End w/ mock repository
2) Integration only at Repository level using in-memory DB (Derby, H2)
By doing this, we were able to speed up the test significantly.
I believe in Rails, you're tied with ActiveRecord and would require real database (be it SQLite3). There may be open source libraries that can intercept AR calls and re-route it to either fake DB or just simply fake 'em all, but not sure how popular/complete they are.
- scottschulthess 14y agoWell I think it depends, sqlite can behave as an entirely in-memory database I think - so what would be the difference between that and a pure ruby in-memory database, really? If you want to just fake 'em all, which does not sound particularly ideal, people just generally mock em
- edwinnathaniel 14y agoYes, my bad for not clarify it: mock the repository part, but not to mock as an entire ActiveRecord. for example: FriendsRepository.java is an interface that can be mocked during unit-test while the integration-test would use the actual implementation. I know that the Java solution tend to be brittle because it somewhat forces people to have 1 interface, 1 class implementation (the mock implementation would be provided by mocking library).