OT:M$ ASP vs PHP and code reuse
Digital Wokan
plug-discuss@lists.plug.phoenix.az.us
Wed, 23 Jan 2002 20:31:08 -0700
Code reuse tends to fall basically into include directives (including
PHP's require commands). PHP definitely has the advantage here. For
one, the include and require commands are within the script context, as
opposed to having to "step out" of your code segment...
PHP:
<?php
... php code ...
include("inc-menu.php");
... php code ...
?>
ASP:
<%
... asp code ...
%>
<!--#include file="inc-menu.asp"-->
<%
... asp code ...
%>
ASP shifts back into HTML only to find it's got to do an about-face and
parse an ASP directive, then as it finishes that and resumes HTML
sending, it once again does an immediate about-face into ASP parsing.
My only guess is that MS was trying to not add yet another command that
didn't exist in the other "versions" of VB they produce. (It can be
maddening to find functions that exist in only one or two parts of the
VB/VBA/VBS triumvirate, especially when you find that fact out by
attempting to use a function you knew and loved.)
Another bonus PHP gives you over ASP is that it includes the
"include_once" command, allowing you to write a class definition that
can include_once it's parental declarations if necessary without fear of
reincluding a file.
Accomplishing this in ASP requires added coding to make sure something
hasn't already been defined (think #IFDEF from C/C++). My first run-in
with this is the ubiquitous adovbs.inc file from Microsoft itself. It
defines many constants for use with ADO. I wrote a script to handle
database access and included adovbs.inc to define the necessary
constants. What I didn't know was that a cohort of mine had written a
reusable function that required use of ADO objects and had used an
include in his file to make sure adovbs.inc was executed. Wonderful
errors abound when you accidentally try to redifine previously defined
constants under ASP/VBS. We ended up removing his include and adding a
remark at the top of his file that the main ASP script should include
the adovbs.inc file. Hardly the preferred black-box solution of OO
programming techniques.
Under PHP, we would have each been using the "include_once" commands and
this kind of situation would never have occurred.
"Furmanek, Greg" wrote:
>
> Since the last one was a silly question maybe this one is better.
> I would like to know if there are any references on design issues
> of PHP or ASP. How to break out modules, how to reuse code. stuff
> like that.
>
> Greg
>
> > -----Original Message-----
> > From: Furmanek, Greg [mailto:Greg.Furmanek@hit.cendant.com]
> > Sent: Wednesday, January 23, 2002 10:49 AM
> > To: 'plug-discuss@lists.plug.mybutt.net'
> > Subject: RE: OT:M$ ASP
> >
> >
> > I guess I should have learned not to ask silly question here.
> >
> >
> >
> > > -----Original Message-----
> > > From: Digital Wokan [mailto:wokan@home.com]
> > > Sent: Sunday, January 20, 2002 11:02 AM
> > > To: plug-discuss@lists.plug.mybutt.net
> > > Subject: Re: OT:M$ ASP
> > >
> > >
> > > Core's PHP Programming is a great reference. (And is far
> > more capable
> > > on that NT/2K system than the pre-installed web scripting language
> > > supplied.)
> > >
> > > Ask a silly question on a Linux list. Get a silly answer on a Linux
> > > list.
> > >
> > > "Furmanek, Greg" wrote:
> > > >
> > > > Since this is the best source of info on computing PERIOD I
> > > would like
> > > > a recommendation on book regarding ASP programming.
> > > >
> > > > Thanks.
> > > >
> > > > Greg.
> > > ________________________________________________
> > > See http://PLUG.phoenix.az.us/navigator-mail.shtml if your
> > > mail doesn't post to the list quickly and you use Netscape to
> > > write mail.
> > >
> > > PLUG-discuss mailing list - PLUG-discuss@lists.plug.mybutt.net
> > > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> > >
> >
> >
> > "The sender believes that this E-mail and any attachments
> > were free of any
> > virus, worm, Trojan horse, and/or malicious code when sent.
> > This message
> > and its attachments could have been infected during transmission. By
> > reading the message and opening any attachments, the
> > recipient accepts full
> > responsibility for taking protective and remedial action
> > about viruses and
> > other defects. The sender's employer is not liable for any
> > loss or damage
> > arising in any way from this message or its attachments."
> > ________________________________________________
> > See http://PLUG.phoenix.az.us/navigator-mail.shtml if your
> > mail doesn't post to the list quickly and you use Netscape to
> > write mail.
> >
> > PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
> > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> >
>
> "The sender believes that this E-mail and any attachments were free of any
> virus, worm, Trojan horse, and/or malicious code when sent. This message
> and its attachments could have been infected during transmission. By
> reading the message and opening any attachments, the recipient accepts full
> responsibility for taking protective and remedial action about viruses and
> other defects. The sender's employer is not liable for any loss or damage
> arising in any way from this message or its attachments."