Connecting to Database
It’s not clearly mentioned when to connect to the database. So, here goes my idea.
If the application is going to hit frequently by a large number of clients, we can connect to the database by calling
dao.connect() on main and keeping the connection persistent.
Another way is to connect and disconnect each time you run a query. This may work better in case of less frequent access.
In all the above db helpers, the MoviesDAO object is not used. However keeping the helpers as methods of MoviesDAO gives clarity to code. So instead of calling
dao.connect and then the helper each time, the connect can be called inside the helper as
Better suggestions are welcomed!!