ways of developing robust libraries - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: ways of developing robust libraries (/showthread.php?tid=61578) |
ways of developing robust libraries - Spiker - 04-27-2015 I was thinking few weeks ago on how to build libraries in order to have easier time testing them and to enable them to hold more information (hold information such as: what has happened, rather than putting log_message or similar to know where the issue is , i.e. have some error reporting built in). Additionally to that it would be great to save the action that have happened in the system. While developing the library I have followed couple of rules: - Function in the class should return a resource or we have an error (FALSE) - I don't use form_validation inside the class. I think it's controller related. I guess, if to do it in the library, the best way to do it would be using magic methods? In the library that I have attached we have 2 main functions to fetch list of messages and fetch a message itself. Also we have 4 support functions to enable you to set / fetch system code / status. And also we have __construct and setUserId which are self-explanatory. It would be great to see what you guys think and if there is something similar out their? |