I'm writing an ASP application and have a noob question...
I have a class that access an MS SQL database. I have another class also
accesses an MS SQL database and this second class uses objects from the
first class. I have a third class using the DB and objects of the second
class.
Each of these classes contain all the code needed to access the database and
this means much duplicated code. What I'd like to know is if there is a way
to avoid the duplicated code?
I know I could write the code once, then do an #include to include the code
into the class, but that still means multiple occurances of the code.
??? 10 2296
Noozer wrote: I'm writing an ASP application and have a noob question...
I have a class that access an MS SQL database. I have another class also accesses an MS SQL database and this second class uses objects from the first class. I have a third class using the DB and objects of the second class.
Each of these classes contain all the code needed to access the database and this means much duplicated code. What I'd like to know is if there is a way to avoid the duplicated code?
I know I could write the code once, then do an #include to include the code into the class, but that still means multiple occurances of the code.
What do you mean by "class" ? Are you talking about VBScript Class Objects
created by using the Class Statement
( http://msdn.microsoft.com/library/en...1f669ec5.asp)?
Do you mean custom objects written in JScript? ActiveX objects you
instantiate with Server.CreateOb ject("prog.id") ?
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
"Dave Anderson" <GT**********@s pammotel.com> wrote in message
news:12******** ****@corp.super news.com... Noozer wrote: I'm writing an ASP application and have a noob question...
<snip> Each of these classes contain all the code needed to access the database and this means much duplicated code. What I'd like to know is if there is a way to avoid the duplicated code?
What do you mean by "class" ? Are you talking about VBScript Class Objects created by using the Class Statement (http://msdn.microsoft.com/library/en...1f669ec5.asp)?
Yes, exactly.
Noozer wrote: Are you talking about VBScript Class Objects created by using the Class Statement?
Yes, exactly.
OK. Could you be a little more specific about what you are doing? Perhaps
you could show an example that illustrates your question.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
"Noozer" <do*******@me.h ere> wrote in message
news:VncMf.7266 7$H%4.28156@pd7 tw2no... I'm writing an ASP application and have a noob question...
I have a class that access an MS SQL database. I have another class also accesses an MS SQL database and this second class uses objects from the first class. I have a third class using the DB and objects of the second class.
Each of these classes contain all the code needed to access the database and this means much duplicated code. What I'd like to know is if there is a way to avoid the duplicated code?
I know I could write the code once, then do an #include to include the code into the class, but that still means multiple occurances of the code.
Have you considered redesigning your set of classes so that none of them
duplicate each other's functionality? Code a common low-level class that
the others can call to do their dirty work. If that's impractical, put the
redundant code in regular functions and call them from the classes.
Also try to avoid any unnecessary depth in your object dependency trees,
e.g., ClassC depends on ClassB which depends on ClassA, etc... I'm not
saying never to do this, just to keep it to the minimum that's needed.
If you want to post the classes you're using (or perhaps abbreviated
versions if possible) we may be able to offer more specific suggestions.
-Mark
"Noozer" <do*******@me.h ere> wrote in message
news:VncMf.7266 7$H%4.28156@pd7 tw2no... I'm writing an ASP application and have a noob question...
I have a class that access an MS SQL database. I have another class also accesses an MS SQL database and this second class uses objects from the first class. I have a third class using the DB and objects of the second class.
Each of these classes contain all the code needed to access the database and this means much duplicated code. What I'd like to know is if there is a way to avoid the duplicated code?
I know I could write the code once, then do an #include to include the code into the class, but that still means multiple occurances of the code.
???
Unfortunately, VBScript does not allow for the redefinition of classes. You
could do it in JScript. Your options would be to rewrite the classes in
JScript or create JScript wrapper classes/functions for your existing
VBScript classes.
"Mark J. McGinty" <mm******@spamf romyou.com> wrote in message
news:e8******** ******@TK2MSFTN GP09.phx.gbl... "Noozer" <do*******@me.h ere> wrote in message news:VncMf.7266 7$H%4.28156@pd7 tw2no... I'm writing an ASP application and have a noob question...
I have a class that access an MS SQL database. I have another class also accesses an MS SQL database and this second class uses objects from the first class. I have a third class using the DB and objects of the second class.
Each of these classes contain all the code needed to access the database and this means much duplicated code. What I'd like to know is if there is a way to avoid the duplicated code?
I know I could write the code once, then do an #include to include the code into the class, but that still means multiple occurances of the code.
Have you considered redesigning your set of classes so that none of them duplicate each other's functionality? Code a common low-level class that the others can call to do their dirty work. If that's impractical, put the redundant code in regular functions and call them from the classes.
Also try to avoid any unnecessary depth in your object dependency trees, e.g., ClassC depends on ClassB which depends on ClassA, etc... I'm not saying never to do this, just to keep it to the minimum that's needed.
If you want to post the classes you're using (or perhaps abbreviated versions if possible) we may be able to offer more specific suggestions.
Thanks all!
Basically, I'm trying to design some very generic classes that I will use
often in multple projects. Because of this, I was building each class to be
self sustaining, containing any code needed to converse with databases,
generate output etc. With this, I'd have a lot of duplicated code if I was
using several of the classes at the same time.
Reading the replies here and planning a bit more, it makes much more sense
to build even more basic classes (like a database class) for anything that
I'll be using that often, and being sure to include them in the PROJECT (ie,
ASP) page and NOT within the classes themselves. Such as:
<!-- #include file="dbclass.i nc" --> JUST DB handler code
<!-- #include file="pageclass .inc" --> JUST code about pages
<!-- #include file="bookclass .inc" --> JUST code about books
....instead of...
<!-- #include file="bookclass .inc" --> Code about books, DB handler for book
related info, and has an #include to import the "pageclass. inc" file, which
has it's own DB handler for page related info.
Noozer wrote: "Mark J. McGinty" <mm******@spamf romyou.com> wrote in message news:e8******** ******@TK2MSFTN GP09.phx.gbl... "Noozer" <do*******@me.h ere> wrote in message news:VncMf.7266 7$H%4.28156@pd7 tw2no... I'm writing an ASP application and have a noob question...
I have a class that access an MS SQL database. I have another class also accesses an MS SQL database and this second class uses objects from the first class. I have a third class using the DB and objects of the second class.
Each of these classes contain all the code needed to access the database and this means much duplicated code. What I'd like to know is if there is a way to avoid the duplicated code?
I know I could write the code once, then do an #include to include the code into the class, but that still means multiple occurances of the code.
Have you considered redesigning your set of classes so that none of them duplicate each other's functionality? Code a common low-level class that the others can call to do their dirty work. If that's impractical, put the redundant code in regular functions and call them from the classes.
Also try to avoid any unnecessary depth in your object dependency trees, e.g., ClassC depends on ClassB which depends on ClassA, etc... I'm not saying never to do this, just to keep it to the minimum that's needed.
If you want to post the classes you're using (or perhaps abbreviated versions if possible) we may be able to offer more specific suggestions.
Thanks all!
Basically, I'm trying to design some very generic classes that I will use often in multple projects. Because of this, I was building each class to be self sustaining, containing any code needed to converse with databases, generate output etc. With this, I'd have a lot of duplicated code if I was using several of the classes at the same time.
Reading the replies here and planning a bit more, it makes much more sense to build even more basic classes (like a database class) for anything that I'll be using that often, and being sure to include them in the PROJECT (ie, ASP) page and NOT within the classes themselves. Such as:
<!-- #include file="dbclass.i nc" --> JUST DB handler code <!-- #include file="pageclass .inc" --> JUST code about pages <!-- #include file="bookclass .inc" --> JUST code about books
...instead of...
<!-- #include file="bookclass .inc" --> Code about books, DB handler for book related info, and has an #include to import the "pageclass. inc" file, which has it's own DB handler for page related info.
You might want to look at this post wrt include file extensions: http://groups.google.co.uk/group/mic...c14a5ae7975140
/P. <!-- #include file="bookclass .inc" --> Code about books, DB handler for book related info, and has an #include to import the "pageclass. inc" file, which has it's own DB handler for page related info.
You might want to look at this post wrt include file extensions:
http://groups.google.co.uk/group/mic...c14a5ae7975140
I always wondering about which extension to use. I had just recently
switched away from .asp to .inc. Back I go!!!
Thanks!
Noozer wrote: I always wondering about which extension to use. I had just recently switched away from .asp to .inc. Back I go!!!
There is no reason to go back. You can simply tell IIS to parse .inc
requests with asp.dll, and there will be no functional difference between
the extensions.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David MacQuigg |
last post by:
I have what looks like a bug trying to generate new style classes with
a factory function.
class Animal(object): pass
class Mammal(Animal): pass
def newAnimal(bases=(Animal,), dict={}):
class C(object): pass
C.__bases__ = bases
dict = 0
|
by: Bryan Parkoff |
last post by:
I have C++ Primer Third Edition -- Author Stanley B. Lippman and Josee
Lajoie. I have been studying it for couple months however it does not
provide a valuable information which it is about "friend to class". I am
very disappointed because it is the way how C++ Compiler is designed. I
assume that "friend to class" is not the good option.
If CMain class is initialized before CA class, CB class, and CC class
are initialized inside CMain...
|
by: Skybuck Flying |
last post by:
Hi,
I would like to split main.c which contains all code into the following
Step 1. Machine.h
Step 2. drand.h and drand.c
Step 3. nrand.h and nrand.c
Main.c then only contains some test code.
|
by: teslar91 |
last post by:
As a fairly new .NET coder, I would greatly appreciate some comments on
any .NET classes that are known to be notoriously slow by comparison to
direct API calls.
I've already had a bad experience with System.IO.DirectoryInfo. My
requirements were to recursively scan a folder, recording all
filenames/dates/sizes/attribs. The target folder contained 88,000
files and 5,000 subfolders.
I originally used System.IO.DirectoryInfo and found...
|
by: devicerandom |
last post by:
Hi,
I am currently using the Cmd module for a mixed cli+gui application. I
am starting to refactor my code and it would be highly desirable if
many commands could be built as simple plugins.
My idea was:
- Load a list of plugin names (i.e. from the config file, or from the
plugins directory)
- Import all plugins found dynamically:
| |
by: iKiLL |
last post by:
hi all,
I would like to be able to create an umbrella class for all my main global
sections but I would still like to keep them all in separate file something
like the below but I keep getting an error saying you are not allowed
Multiple base classes.
/// <summary>
|
by: Larry Smith |
last post by:
I just read a blurb in MSDN under the C++ "ref" keyword which states that:
"Under the CLR object model, only public single inheritance is supported".
Does this mean that no .NET class can ever support multiple inheritance. In
C++ for instance I noticed that the compiler flags an error if you use the
"ref" keyword on a class with multiple base classes. This supports the above
quote. However, under the "CodeClass2.Bases" property (part...
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms.
Here is a newbie mistake that I found myself doing (as a newbie), and
that even a master programmer, the guru of this forum, Jon Skeet,
missed! (He knows this I'm sure, but just didn't think this was my
problem; LOL, I am needling him)
If...
|
by: =?Utf-8?B?QmV0aA==?= |
last post by:
Hello.
I'm trying to find another way to share an instance of an object with other
classes.
I started by passing the instance to the other class's constructor, like this:
Friend Class clsData
Private m_objSQLClient As clsSQLClient
Private m_objUsers As clsUsers
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |