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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.