Page 2 of 2
Posted: Mon Nov 06, 2006 1:13 pm
by MrPotatoes
d11wtq wrote:MrPotatoes wrote:ok. some people use libraries and classes as a different folder? why? i've never done this so i don't know. what is different between a library and a class? i basically have them set up the same.
explain

Library: A collection of components and interfaces providing extended functionality to the developer.
Class: A component itself acting as a container for properties and methods and an interface for an object.
You're right, there's not really a difference. It's just often that libs need to hold their own directory structure since the developer may have built them to work based upon that structure. We've also used schmes like "classes/3rd-party/<.....>". It's mostly just so that __autoload() can read from a nice cleanly organised directory.
yeah, this is what i thought. normally i would call a library an API but so much computer terminology is so vague and starts to pour into other terminology so i try to stick to the basics. everything else i try to stay away from lol
Posted: Mon Nov 06, 2006 6:29 pm
by Ambush Commander
Well, a library definitely does not equal an API. A library has an API, but not vice versa.
Posted: Mon Nov 06, 2006 6:37 pm
by Christopher
Ambush Commander wrote:Well, a library definitely does not equal an API. A library has an API, but not vice versa.
Would that be because an API is an interface? Specifically one that you use when programming applications?

Posted: Mon Nov 06, 2006 6:39 pm
by MrPotatoes
well DX and OGL are api's. the MySQL extension in PHP5 could be considered an API. so where and what are the libraries?
not that it matters too much but this is one of those things that were never explained too well i guess lol
Posted: Mon Nov 06, 2006 6:42 pm
by Ambush Commander
Here's how I understand it:
Library - A well-defined component that offers a specific set of useful functionality that would not by itself qualify as an application
Wrapper - A design pattern that abstracts calls to an external component into a more friendly interface (mysql extension)
API - An interface a library or wrapper gives to the developer to use. Usually these are internal, but APIs can also be used to refer to external SOAP or XML-RPC interfaces.
Posted: Mon Nov 06, 2006 6:45 pm
by Luke
the wrapper pattern is called the facade pattern a lot (fyi)
Posted: Mon Nov 06, 2006 7:19 pm
by Christopher
A library is the code that does things -- for example is GD which is an image library An API is a clearly defined, usually documented, interface to the library code -- for example GD has APIs for PHP, C++ and VisualC++. All those interfaces access the same library. So the API is the way the program uses the library.
Posted: Tue Nov 07, 2006 3:09 am
by Jenk
MrPotatoes wrote:well DX and OGL are api's. the MySQL extension in PHP5 could be considered an API. so where and what are the libraries?
not that it matters too much but this is one of those things that were never explained too well i guess lol
No, DX and OpenGL
have API's, The MySQL extension
has an API.
They are not API's, but they have API's.
Application
Programming
Interface.
Posted: Tue Nov 07, 2006 6:32 am
by Maugrim_The_Reaper
Library: A collection of functional components, classes or functions.
Class: A specific unit of functionality.
API: A set of public methods/properties programmers use to interact with a class.
An API is not a standalone entity. It's a feature of a class or library. If you take a PHP5 class, the API is the collection of public methods and properties which a programmer can access. If you take something like GD, the API are public methods available to a programmer to access the GD Library from within PHP. Many API's may be Facades - these are not standalone entities either, they're part of a class which proxies to another set of classes either to simplify usage or give disparate libraries an identical interface (so they're interchangeable to a degree).