Site Layout \ foundation : how do you do yours?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post 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
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Well, a library definitely does not equal an API. A library has an API, but not vice versa.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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? ;)
(#10850)
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post 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
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

the wrapper pattern is called the facade pattern a lot (fyi)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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.
(#10850)
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post 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.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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).
Post Reply