112 Chapter 3 Application Design: A Real-Life Example
114 Chapter 3 Application Design: A Real-Life Example As you can see, plug-ins offer an extremely powerful way of extending a complex system. Consequently, phpChat has abstracted most of its own internals into plug-ins as well.The complete command interpreter has been moved into a plug-in,as well as the complete set of text formatting/printing procedures.This means that there is only a solid kernel that doesn t have to be changed because there s simply nothing in there that would require changing the rest can be freely modified, extended, even removed, without any impact on system performance or operability. Have you ever seen an application that doesn t complain about someone deleting its files? Using this technique, an application won t complain and will even dynamically adapt to it. Plug-ins can be used in many ways, not just for chat programs. For example, you could also build a portal site consisting of the traditional news page, an email interface, etc. Using plug-ins, you can design a site kernel that handles all basic issues such as providing page layout, database back end, sessioning, and so on. Based on the site kernel, you can then create plug-ins for displaying news, sending and receiving email, even for providing different methods of logging in. Even if it s quite an effort, we encourage you to create a plug-inbased application as an exercise. It will be worth the work. Listing 3.4 shows a plug-in template implementing a dummy plug-in as code base for new plug-ins. Listing 3.4 A plug-in template. // // Use these variables to tell the plug-in installer how you named your // initialization and deinitialization functions. This is done to eliminate // the need for changing the installer code, which would ask for errors. // $plugin_init_function = myplugin_init ; $plugin_deinit_function = myplugin_deinit ; // // // ////////////////////////////////////////////////////////////////////////////// // // myplugin_idle_callback(int code, mixed parameter) - example callback // ////////////////////////////////////////////////////////////////////////////// //
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services