Re: DBMS that integrates well with object-oriented programming

2001-11-18 Thread Ilya Martynov


BH After converting the data in my project from text files to MySQL
BH tables, things are certainly working more smoothly than they were
BH before, but since I use objects (in Perl, which barely supports
BH objects, but that's another story) I have to write a lot of annoyingly
BH repetitive code to create the object, run a query on the database to
BH get the data that I need, set the object's member variables equal to
BH the results returned from the query, and then do all those steps in
BH reverse if the object's member values have changed later.

There is a number of CPAN modules which provide OO access for SQL database.
Take a look at http://poop.sourceforge.net.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)|
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)  |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: DBMS that integrates well with object-oriented programming

2001-11-15 Thread Bennett Haselton

At 10:37 AM 11/15/2001 +, [EMAIL PROTECTED] wrote:
Dear Bennett,

On Thu, 15 Nov 2001, Bennett Haselton wrote:
  After converting the data in my project from text files to MySQL 
 tables,
  things are certainly working more smoothly than they were before, but 
 since
  I use objects (in Perl, which barely supports objects, but that's 
 another
  story) I have to write a lot of annoyingly repetitive code to create 
 the
  object, run a query on the database to get the data that I need, set 
 the
  object's member variables equal to the results returned from the query, 
 and
  then do all those steps in reverse if the object's member values have
  changed later.

Hmm... I'm sure plenty of people would disagree strongly with your remark
of bad OO support in Perl. But, that is beside the point. You could either
search CPAN (http://www.cpan.org/) and see if you find what you need there
(Surely somebody had the same problem already), and if not, take a look at
the AUTOLOAD magic sub in Perl (that'd be perldoc perlsub, search for
'Autoloading').

I can't do it in Perl.  I can't even quantify the amount of money we've 
already lost by using Perl.  By not supporting OO, I mean things like the 
fact that if you define a member function of a class, then
 $classname::functionname($arg1, $arg2);
and
 $classname-functionname($arg1, $arg2);
will both compile, but one is a static function that passes the class name 
as the first argument, and the other is a non-static function that passes 
the arguments as listed.  No one on any Perl list that I'm on could make 
sense of why they did that.  If you wanted a static function, you'd make it 
static; otherwise, you'd make it non-static.  The way Perl does it, you 
have to put some logic at the beginning of your function to check whether 
the first argument is the class name, and if it is, branch into the 
static function code, or else branch to the non-static function 
code.  Bizarre.  I think that to the maximum extent possible, a programming 
language should ensure that a typo will cause the program *not to run*, 
instead of running and doing something unexpected.

Has anyone used a beta of Visual Studio .NET enough to know if it can do 
all of this?  i.e. being able to do something along the lines of
 user myuser = user.GetObjectFromTableRow(bennett);
 myuser.sendReminders();
 myuser.emailaddress = '[EMAIL PROTECTED]';

in three lines -- with Perl and MySQL it takes about 20.

I think there are some purposes that free, open-source software is better 
suited for (security protocols and other well-defined problems that don't 
change with a constantly changing technological environment), however the 
question of when and when not to use open source software is clouded by the 
notion that open-source software is always better.  If I'm going to be 
using an IDE to do rapid application development, I want a 
**closed-source**, **proprietary** system that **costs money** :)

 -Bennett

[EMAIL PROTECTED] http://www.peacefire.org
(425) 649 9024


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: DBMS that integrates well with object-oriented programming

2001-11-15 Thread Michael T. Babcock

On Thu, Nov 15, 2001 at 01:49:31AM -0800, Bennett Haselton wrote:
 my $user = user.CreateFromTableRow(bennett);
 $user.sendReminderEmails();
 $user.emailaddress = '[EMAIL PROTECTED]';
 
You would lose some indexing features, etc., but you could easily use a 
language like Python that allows for object serialization and simply 
store the serialized objects in the database (look up 'pickle' on 
python.org).  This is also true with PHP.

1) Create object (class)
2) Use object
3) Serialize  store object

later ...

4) Fetch  deserialize object
5) Use object
6) Re-serialize and store object
-- 
Michael T. Babcock
CTO, FibreSpeed Ltd.

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: DBMS that integrates well with object-oriented programming

2001-11-15 Thread Jeremy Zawodny

On Thu, Nov 15, 2001 at 01:49:31AM -0800, Bennett Haselton wrote:

 After converting the data in my project from text files to MySQL
 tables, things are certainly working more smoothly than they were
 before,

Good to hear.

 but since I use objects (in Perl, which barely supports objects, but
 that's another story)

What does that mean, exactly?  I do a lot of OO in Perl.

 I have to write a lot of annoyingly repetitive code to create the
 object, run a query on the database to get the data that I need, set
 the object's member variables equal to the results returned from the
 query, and then do all those steps in reverse if the object's member
 values have changed later.

Well, it *is* Perl.  If you find yourself doing something repetitive,
the little programmer in your head should wake up and think how can I
write a program to do all this repetitive work so that I can sit on a
tropical beach? :-)

 Are there any database systems that integrate so smoothly with an
 object-oriented programming language that I would be able to write
 code like:
 
 my $user = user.CreateFromTableRow(bennett);
 $user.sendReminderEmails();
 $user.emailaddress = '[EMAIL PROTECTED]';
 
 and the appropriate values would get read and written to the
 underlying database table.  There's no reason why a language/IDE
 designed to integrate databases and objects would require more than
 three lines of code for that.

I was in a discussion about this a week or so ago with a co-worker.
We could decide if it ought to be Ruby, Python, or C++.  But we had
some interesting ideas that would be fun to try and implement someday.

I don't know of one yet, but I've heard good things about Zope's
object database (ZODB?)

 An ideal database and language integration system could have the following 
 features:
 (a) there is an automatic one-to-one correspondence between fields in a 
 database table and member variables of the object

In Perl, you can used a tied hash to do that already.

 (b) any field that is a unique key

What's that mean?

 (c) modifications of the object member variable values get written through 
 directly to the database

Tied hashes do that, too.

 (d) queries can be done in-place, in code, with a function that takes a 
 reference to another function and returns all elements in the table for 
 which that function returns true, i.e. this example in pseudocode would 
 return an array of all objects corresponding to rows in the table 
 automobile where the price is less than 1:
 my @user_array = GetMatches('automobile_table',
   function myfunc($automobile)
   {
   if ($automobile.price  1)
   {
   return true;
   }
   }
   );

That doesn't look to hard to do, either.  Have you looked at all the
database related modules on the CPAN?

Jeremy
-- 
Jeremy D. Zawodny, [EMAIL PROTECTED]
Technical Yahoo - Yahoo Finance
Desk: (408) 349-7878   Fax: (408) 349-5454   Cell: (408) 685-5936

MySQL 3.23.41-max: up 71 days, processed 1,555,776,471 queries (253/sec. avg)

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: DBMS that integrates well with object-oriented programming

2001-11-15 Thread Jeremy Zawodny

On Thu, Nov 15, 2001 at 03:18:58AM -0800, Bennett Haselton wrote:
 
 Hmm... I'm sure plenty of people would disagree strongly with your
 remark of bad OO support in Perl. But, that is beside the
 point. You could either search CPAN (http://www.cpan.org/) and see
 if you find what you need there (Surely somebody had the same
 problem already), and if not, take a look at the AUTOLOAD magic
 sub in Perl (that'd be perldoc perlsub, search for 'Autoloading').
 
 I can't do it in Perl.

What's it?

 I can't even quantify the amount of money we've already lost by
 using Perl.

Funny, I can't imagine to begin to quantify the amount of time (or
money) we've saved by using Perl!

But this isn't a language war (yet?).

 By not supporting OO, I mean things like the fact that if you define
 a member function of a class, then

  $classname::functionname($arg1, $arg2);
 and
  $classname-functionname($arg1, $arg2);

 will both compile, but one is a static function that passes the
 class name as the first argument, and the other is a non-static
 function that passes the arguments as listed.

What's the prototype on functionname() look like?  Using a prototype
of ($$$) would have made that a compile-time error, so don't blame
Perl!

 No one on any Perl list that I'm on could make sense of why they did
 that.

Why who did what?

 If you wanted a static function, you'd make it static; otherwise,
 you'd make it non-static.

How, exactly?

 The way Perl does it, you have to put some logic at the beginning of
 your function to check whether the first argument is the class name,
 and if it is, branch into the static function code, or else branch
 to the non-static function code.

Well, most folks write methods and only write them to be called as
methods.  If their first argument isn't an object ref, they should
bail.

Mixing static and dynamic stuff in a single function doesn't sound
like a good idea to me (unless you're talking about new(), which is
typically a constructor).

 Bizarre.  I think that to the maximum extent possible, a programming
 language should ensure that a typo will cause the program *not to
 run*, instead of running and doing something unexpected.

Oh, you just want a strictly typed language.  Then Perl is certainly
not for you.  Maybe C++ is more up your alley.

 Has anyone used a beta of Visual Studio .NET enough to know if it can do 
 all of this?  i.e. being able to do something along the lines of

Which language?  .NET is not a language.  It's a framework.

  user myuser = user.GetObjectFromTableRow(bennett);
  myuser.sendReminders();
  myuser.emailaddress = '[EMAIL PROTECTED]';
 
 in three lines -- with Perl and MySQL it takes about 20.

Assuming that someone has already built a good user class, you can
also do it in three lines of Perl.  Or Python.  Or VisualBasic.  Or
whatever.  I think that then language really isn't the issue in this
case.

 I think there are some purposes that free, open-source software is
 better suited for (security protocols and other well-defined
 problems that don't change with a constantly changing technological
 environment), however the question of when and when not to use open
 source software is clouded by the notion that open-source software
 is always better.  If I'm going to be using an IDE to do rapid
 application development, I want a **closed-source**, **proprietary**
 system that **costs money** :)

And you're free to choose whatever you'd like.  I've used both and
have had success with both.

Jeremy
-- 
Jeremy D. Zawodny, [EMAIL PROTECTED]
Technical Yahoo - Yahoo Finance
Desk: (408) 349-7878   Fax: (408) 349-5454   Cell: (408) 685-5936

MySQL 3.23.41-max: up 71 days, processed 1,555,847,080 queries (253/sec. avg)

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php