Welcome Guest, Not a member yet? Register   Sign In
Ask about library
#2

0. Use English identifiers, otherwise it is it is very hard reading code. "Donaturlib" name does not tell me anything about he purpose of this library.

1. See http://www.codeigniter.com/userguide3/ge...aries.html This is the formal, technical explanation about libraries. From your perspective there are two main reasons for making libraries: just to collect code within relatively independent methods; or to use OOP - then you have classes that are aspect focused, the methods serve a concrete functionality. CodeIgniter libraries at the moment follow the singleton pattern (other instances may be created under different property names), they also have a conventional way to access in initialization specific to them configuration options.

2. There is room for criticism about your library. At the moment it is small, but it tends to do many things alone. Try to split the concerns, let this library have a singlepurpose. For example, the getPeople($username) method IMO should be in a separate model that deals with the users. You have HTML code inside the method is_admin(), the place is not right, HTML usually is within views. The method security() seems pretty exotic. It is not clear why do you use cookies directly, also, I don't see encryption/decryption of these cookies.

3. The difference between models and libraries is technical. Models don't have the same access on initialization to the configuration options as libraries have, but models have a property for accessing the database. Semantically there may be no difference, you may implement business logic as a model (usually) or as a library. A shopping cart could be a library or it could be a model.

Here I share my subjective perception, of course.
Reply


Messages In This Thread
Ask about library - by bobykurniawan - 11-05-2014, 09:39 AM
RE: Ask about library - by ivantcholakov - 11-05-2014, 11:37 AM
RE: Ask about library - by bobykurniawan - 11-05-2014, 08:44 PM
RE: Ask about library - by ivantcholakov - 11-05-2014, 10:23 PM
RE: Ask about library - by bobykurniawan - 11-06-2014, 08:37 PM
RE: Ask about library - by ivantcholakov - 11-06-2014, 11:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB