Pros and Cons of using Singleton Pattern in DAL

前端 未结 6 1597
感动是毒
感动是毒 2021-02-06 16:26

I have asked to use singleton pattern implemented DAL, but I think its difficult to pool the connections,use transactions..etc

I would like to know the pros and cons and

6条回答
  •  佛祖请我去吃肉
    2021-02-06 17:24

    Using a singleton for the database connection factory in the DAL is pretty common. It lets you more easily plug in different implementations of the factory without changing a lot of code. A lot of people don't seem to like the singleton pattern, but I think it works ok for this type of thing.

提交回复
热议问题