Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #2374 > unrolled thread
| Started by | Win User <winuser@ms.invalid> |
|---|---|
| First post | 2012-10-22 05:41 +0000 |
| Last post | 2012-10-27 12:30 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.programming
Object or String? Win User <winuser@ms.invalid> - 2012-10-22 05:41 +0000
Re: Object or String? "LudovicoVan" <julio@diegidio.name> - 2012-10-23 01:06 +0100
Re: Object or String? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-10-27 12:30 +0100
| From | Win User <winuser@ms.invalid> |
|---|---|
| Date | 2012-10-22 05:41 +0000 |
| Subject | Object or String? |
| Message-ID | <XnsA0F4585F1A7435x55x5@88.198.244.100> |
=== Question ===
A class has a constructor with arguments, one of which is optional and which
creates a relationship an object whose class is designed to contain ("be
parent to") the object being constructed.
In passing the argument, should the name-as-a-string of the instantiated
object (not its class name) be passed to the constructor, which cannot
verify the nature of object as a string,
OR
should the object (hopefully just its reference [using PHP]) be passed an
argument, enabling the constructor to verify its status using an
"instanceof" operator and possibly to extract the name of the object,
probably via a getter function, since the instance "name" will be a private
member variable?
=== Background: Elaboration ===
I am creating a "system" which describe the structure of all or select
databases on a database system, using classes (in PHP):
one
class server
has one or more
class database
has one or more
class table
has one or more
class field
Results of a(ny) database query have a separate structure:
one
class RecordSet
has one or more
class Record
When I go through the initialization procedure, which is to query the
database system on the file system, and to populate memory with the classes,
I will call the server class constructor, which organizes itself and will
call one or more database constructors, which go on to call table
constructors, and so on. The constructor is set up to optionally link
("relate") the object (say a table) to its container/parenter (say a
database).
Should I just pass the name-as-string of the Database object as an argument
to the Table constructor, or should I pass the Database object (preferably
its reference in PHP) as an argument to the constructor and have the Table
constructor verify and extract the name of the Database object using
standard means.
Furthermore, does anyone have a problem or comment at all with the way I am
organizing this? Feel free to give me warnings, notices, or information
related to how to set up this systems of classes and the use of PHP.
[toc] | [next] | [standalone]
| From | "LudovicoVan" <julio@diegidio.name> |
|---|---|
| Date | 2012-10-23 01:06 +0100 |
| Message-ID | <k64n37$cjr$1@dont-email.me> |
| In reply to | #2374 |
"Win User" <winuser@ms.invalid> wrote in message news:XnsA0F4585F1A7435x55x5@88.198.244.100... <snipped> > I am creating a "system" which describe the structure of all or select > databases on a database system, using classes (in PHP): > [...] > Results of a(ny) database query have a separate structure: > [...] > Furthermore, does anyone have a problem or comment at all with the way I > am > organizing this? Feel free to give me warnings, notices, or information > related to how to set up this systems of classes and the use of PHP. Why would you do such a thing at all? Why not just use the database to do what is primarily and optimally a database job? Here are few articles you may find interesting: <http://www.geocities.com/tablizer/whypr.htm> <http://www.thinktecture.com/resourcearchive/architecture-briefings/pure-sql> <http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx> -LV
[toc] | [prev] | [next] | [standalone]
| From | "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> |
|---|---|
| Date | 2012-10-27 12:30 +0100 |
| Message-ID | <Rr2dnbHxJo-cWxbNnZ2dnUVZ8rCdnZ2d@bt.com> |
| In reply to | #2374 |
Win User wrote:
> Should I just pass the name-as-string of the Database object as an
> argument to the Table constructor, or should I pass the Database object
> (preferably its reference in PHP) as an argument to the constructor and
> have the Table constructor verify and extract the name of the Database
> object using standard means.
I can't imagine any advantage at all to /not/ passing the "owning" Database
object to the Table object.
And the chances are that the Table object will never need to ask the Database
object for it's name. E.g. if the table object needs to use its fully
qualified name, then it can ask it owning Database "what is my fully qualified
name, given that my local name is XYZ?" There are other ways of doing this
but they all come to the same thing -- the Database knows the full form of the
name, not the Table.
One reason for that is that the syntax of a name will depend on the DBMS, e.g.
names like:
[MyDatabase].[dbo].[MyTable]
might be appropriate for an MS SQL Server DBMS, but something like:
"MyDatabase"."MySchema"."MyTable"
would be appropriate for a PostgreSQL DBMS. The Database (or perhaps some
other object associated with it -- perhaps a SQLSyntax object or a DBMS object)
should "know" about those kinds of details; it seems (to me) to be wrong that a
Table should have to mess with such details.
-- chris
[toc] | [prev] | [standalone]
Back to top | Article view | comp.programming
csiph-web