Welcome Guest, Not a member yet? Register   Sign In
Libraries or Models, favouritism?
#18

[eluser]Pygon[/eluser]
Here is my personal opinion:

Libraries: Standalone classes/functions. Data interaction is restricted (as best as possible) to that which is supplied by function arguments. Access to methods/functions should be limited (again, as much as possible) to the library sudo-namespace. Processed data is returned to the caller. As jbowman put it, these are "utilities" or tools to accomplish a task.

Model: Data accessor/store. Stores, manipulates and retrieves data from internal or external sources for use by the view. Methods/functions will likely use libraries to aid in data access or manipulation.

Example using a PDF document:

Library contains functions to creates a generic PDF documents and returns this document to the caller. No project specific methods.

Model contains project specific functions for storing data to be contained in a pdf document, methods for manipulating such data prior to creation (within the model), methods which request the library create such document (stored back into the model) and methods for output to file or browser.

As you can see, in my opinion, a library is generic in nature, has no knowledge of the data you are working with or the source of such data. With little change, a library could work as a standalone php script completely outside of CI. A model, however, would be far more project dependant and unlikely to function as intended outside of CI without heavy modification and dependancies.


Messages In This Thread
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 08:28 AM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 10:41 AM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 10:46 AM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 02:59 PM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 04:54 PM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:33 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:43 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 02:13 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 02:24 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:05 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:20 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:34 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:42 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:50 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 04:26 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 08:08 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 08:40 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 10:23 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 10:33 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 11:34 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:01 PM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:41 PM
Libraries or Models, favouritism? - by El Forum - 03-29-2008, 10:14 PM
Libraries or Models, favouritism? - by El Forum - 03-29-2008, 10:26 PM
Libraries or Models, favouritism? - by El Forum - 03-29-2008, 10:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB