On Sat, 2002-04-06 at 23:40, brad lafountain wrote: > > --- "Stig S. Bakken" <[EMAIL PROTECTED]> wrote: > > MI is compile-time, aggregate is runtime. That's a big enough reason > > for me. > > I know the difference but how does this benifit you? > > > > > > Class definition is defined at design time not run time! > > > > Aggregate is not really about class definition. The shortcut in the > > current implementation modifies the class definition, but in its basic > > form, aggregation is about forwarding calls, not about changing class > > definitions. Thus my suggestion to change aggregate as in my first > > reply to Kristian. > > Ok... Can you give me a good example that aggergate would be used over MI. > That makes sence and isn't garbage code!
Okay, a good example could be a database abstraction layer supporting ODBC with special handling of each database behind ODBC. For example, if you use ODBC to talk with MySQL, Oracle or Solid, you have three ways of dealing with sequences (mysql only has auto_increment fields, Oracle has real sequences, but for Solid 2.x you need to define and use a procedure to get sequence values). If you use iODBC to do all this, you won't know which one you're talking to until after connecting. Example set of classes using aggregate to customize at runtime: DB_Connection generic connection object DB_Connection_odbc layer interfacing to PHP's odbc functions DB_Connection_oracle ditto for Oracle DB_Connection_mysql ditto for MySQL DB_SQL_oracle SQL portability layer for Oracle DB_SQL_mysql ditto for MySQL If the user requests a connection to an Oracle database, the connect function returns an instance of DB_Connection that has aggregated DB_Connection_oracle and DB_SQL_oracle. But if the user requests a connection to Oracle through ODBC, the connect function returns an instance of DB_Connection that has aggregated DB_Connection_odbc. After connecting to the database, DB_Connection_odbc detects that it is used against Oracle and aggregates DB_SQL_oracle. - Stig -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php