Shouldn't classes in DAL (customerDAL) be singleton? Since my controllers (customerController) exposes "Shared Subs", then on every call, there is no need to create a new DAL object if already existed. Correct?
Thanks
Singleton objects are notoriously hard to test. I would look at creating your DAL in such a way that it isn't expensive to instantiate and then creating a new one as needed. This way you'll be able to write unit tests for DAL much more easily and still not incur much overhead. Additionally, if you create the DAL as a singleton, you'll need to be much more concerned with making it thread-safe if you use it in a multi-threaded environment (such as a web app).
If you have a web site singleton dal objects are very dangerous because every request to the site is part of the same application. If you build them wrong, they can become bottlenecks for access to the database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With