Re: class? package?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 11, 2008 at 12:02 PM, Larry Garfield <larry@xxxxxxxxxxxxxxxx>
wrote:

> On Tuesday 10 June 2008, Shelley wrote:
> > Hi all,
> >
> > If you are designing with OO principles, could you give an explanation of
> > what is the difference classes and packages?
> >
> > Several principles talks about classes and packages, such as:
> > The classes in a package are reused together. If you reuse one of the
> > classes in a package, you reuse them all.
> >
> > but few explains the difference between them.
> >
> > When I was summarizing the OO principles, that question confused me:
> >
> http://phparch.cn/index.php/php/43-php-advanced-programming/170-principles-
> >of-object-oriented-design
> >
> > Thanks in advance. :)
>
> A class is a syntactic way of grouping behavior and data together in an
> encapsulated fashion (at least that's the PHP definition).
>
> A formal package is a syntactic way of grouping related classes together,
> either for easier distribution, somewhat tighter coupling, or syntactic
> sugar.  For instance, you could have 5 classes that make up your "Database
> abstraction" package; they're all discrete, but all work in concert.
>
> PHP does not have a syntactic "package" concept.  The closest thing would
> be
> namespaces as implemented in PHP 5.3, but that's not out yet.  Many systems
> emulate packages with verbose class naming (eg, Database_Connection,
> Database_Query, Database_Transaction, Database_Query_Select, etc.), but I
> personally find that ugly. :-)
>
> Thank you very much for the explanation.
I think I got some.
Maybe I am already using them:
I am working on a sns site, and now my practice is grouping classes of a
function
(i.e. subscription) together. When I need it, just load the "package":
subscription.

Right? ;)
-- 
Regards,
Shelley

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux