Re: Using a Resource as a Class Property



Michael Fesser wrote:
.oO(Sanders Kaufman)

So I'm doing it right?! Cool.

It always depends on what you want to achieve. From just looking at the
posted snippet and without knowing what the my_baseclass is supposed to
do, it's hard to tell whether you're doing it right or not, since the
code is not doing anything useful, except for initializing some member
variables.

I know there are some cases where you're supposed to serialize objects instead of... what am I doing, passing by reference? Instantiating?

Aggregating. ;) You create an instance of a class, which is used inside
another object. That's it (in this case).

Serializing can be used if you want to store an object to a file or a
database.

Micha

OK - that was weird, and took some debugging.
I knew there was *something* about scope to deal with here.

I'm aggragating the database object into a base class, and then creating other classes that "extend" that base class.

HOWEVER, in order to do that, I had to move the instantiation(?) of the database class into the extended class. When I had it in the base class, the class that extended it could not see the database properties and functions.

Whew.
.



Relevant Pages

  • Re: OOP and Pear::DB
    ... this method is very enlightening. ... I didn't think to take the database as the base class and extend my ...
    (comp.lang.php)
  • Re: OOD Question
    ... your work order task might have the work order ... instance of the derived classes will give the same information, ... > makes a database call. ... > If theres some change in base class I need to take care of these in all the> derived classes as well. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Scrubbing MySQL Values and CSVtoArray()
    ... Sanders Kaufman wrote: ... then a base class that does the business logic. ... the mysql-specific scrubbing function in the business logic base class - ... it defeats the purpose of putting ALL of the database work in database.php. ...
    (comp.lang.php)
  • Re: Using a Resource as a Class Property
    ... I'm aggragating the database object into a base class, ... other classes that "extend" that base class. ... But if you want to overwrite some methods to ...
    (comp.lang.php)
  • Re: Strongly typed DataSets: Relation between DataTable and TableAdapter
    ... Assuming I create a generic base base class like ... Public MustInherit Class MyBusinessObjectBaseClass(Of TDataRow As DataRow) ... update the database records in the base class. ... Is there a way to get the DataTable a TableAdapter 'belongs' to by code? ...
    (microsoft.public.dotnet.framework.adonet)