What s the best design pattern or best practice for data access (database access or file system access) in Distributed J2EE, .Net Environment, rails or php ?
A:
In the Java world, using DAOs, POJOs, a good ORM, and a 2nd level cache seems to be a very common approach (replace POJOs by Entities 3.x and ORM by JPA if you want).
Actually, I think it applies to .NET too.
With rails or PHP, I don't know the details so I'll let enlightened people answer.
Pascal Thivent
2009-09-26 01:37:15
how about establishing connection in J2EE, would you recommend Service Locator ? Singleton (does it scale well)?
2009-09-26 01:40:44
Use a connection pool. Any decent ORM will be able to lookup a DataSource and obtain connections from a connection pool. Service Locator can still be use but the trend is to use Dependency Injection (DI) and to inject things that you need (including a datasource). Singletons, just forget them.
Pascal Thivent
2009-09-26 02:08:24
A:
There is a your best friend for data access patterns ;) http://martinfowler.com/eaaCatalog/index.html
Andrei Taptunov
2009-09-26 08:56:15