开发者

Do ORM packages implement the Facade or Adapter pattern?

From my understanding the Adapter pattern is basically creating a wrapper on another class so that the class you are wrapping can be used by existing code. A facade is for changing an entire subsystem (so if you are dealing with a complicated drawing api that requires 5 steps you might consolidate them into just 1 method, as an example). My question then is which pattern do ORM's use, or is it both?

They provide a single interface into many different subsystems but I'm still not开发者_开发知识库 sure, though I'm leaning towards the facade pattern.


For the ORM frameworks I know, Adapter does not seem to be a crucial pattern. Facade may be used, e.g. in Hibernate/JPA where there is a single Session/EntityManager interface responsible for almost everything, probably calling a lot of distinct subsystem interfaces behind the curtain.

However, there is a lot of other patterns in play. That the Factory patterns are used often is almost needless to say :-) Another prominent one (in Hibernate at least) is Proxy, which is fundamental in lazy fetching. Furthermore: Object Pool (for the DB connections), Interpreter (for queries)... the list could be continued.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜