I googled, and was informed that a library is made up of multiple relevant classes. But in Codeigniter, I found that there is virtually only one Class in every Library. Sorry for my limited knowledge for this, but I would appreciate it if you could enlighten me a little bit on this. Thank you very much!
Library classes are pre-defined classes which are provided by Java System. There is thousands of library classes and each class contains various functions. These classes provide an effective support to programmers in developing their programs. e.g., Java.lang, Java.util.
[2] A library is a collection of related functionality, whereas a module only provides a single piece of functionality. Which means that, if you have a system with both modules and libraries, a library will typically contain multiple modules.
A class library is a pre-coded object-oriented programming (OOP) template collection. Both network and desktop applications use class libraries. Class libraries contain code for graphical user interface (GUI) elements such as buttons, icons, scroll bars and windows as well as other non-GUI components.
A class defines object properties including a valid range of values, and a default value. A class also describes object behavior. An object is a member or an "instance" of a class. An object has a state in which all of its properties have values that you either explicitly define or that are defined by default settings.
The difference is a semantic one.
A Class is an implementation of a specific piece of functionality (usually completely encapsulating the functionality.
A Library is a collection of units of functionality (or just one) that add functionality. Notice I tried to stay away from the word class in that definition. Libraries can be procedural, functional or OOP. That doesn't detract from the fact that it's a library. Classes just help the abstraction when dealing with OOP.
A Framework is a library that imparts architecture choices on how you write code.
Every framework is therefore a library. Not every library is a framework. CodeIgniter itself can be used as a framework or a library. The difference is if you let the libraries direct your architecture, you're using a framework. If you do not use the architecture bit, it's a library.
It's definitely a pedantic difference, but a significant one. As a gross-over-simplification, if you're doing a formal architecture and understand why everything is layered out how it is for your application specifically, you're using it as a library. If instead you're building it that way because that's how CI does it, that's using a framework. Both have significant benfits, but it's worth understanding the difference.
In general programming terms, not every library has to be made of multiple classes. In fact, not all libraries have to be made up of classes either — it really depends on the implementation (and sometimes the language). As Wikipedia starts off (italics mine):
In computer science, a library is a collection of resources used to develop software. These may include subroutines, classes, values or type specifications.
CodeIgniter has its own definition of "library", in this case it simply calls each third-party application class its own library. Despite that, you can include other classes in the same library file, as long as you have at least one class with the same name as the library file.
Checking the CodeIgniter docs:
When we use the term "Libraries" we are normally referring to the classes that are located in the libraries directory and described in the Class Reference of this user guide. In this case, however, we will instead describe how you can create your own libraries within your application/libraries directory in order to maintain separation between your local resources and the global framework resources.
I don't think of a "library" as specific to a fixed number of classes or files. Does this quote refer to the specific usage that has you confused?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With