Client 3—Making the Connection Code Modular

For our third client, client3, we will make the connection and disconnection code more modular by encapsulating it into functions do_connect() and do_disconnect(), which can be used easily by multiple client programs. This provides an alternative to embedding the connection code literally into your main() function. That's a good idea anyway for any code that's stereotypical across applications. Put it in a function that you can access from multiple programs rather than writing it out in each one. If you fix a bug in or make an improvement to the function, you can change it once and all the programs that use the function can be fixed or take advantage of the improvement just by being recompiled. ...

Get MySQL now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.