-
Incremental testing of n-tier app
If I have Public functions in a "business-layer" DLL, I could just call the
function like this if I set a "reference" to the DLL:
retval = MyBUSDLLFunction(ByVal Param1, ByVal Param2)
However, if I'm not yet ready to create the DLL but want to test the app
during development, including the "business-layer" project in the UI project
group and setting a reference to it doesn't seem to be enough to make this
work. I need to code it:
Set mobjMyBDLL = New MyBDLL.MyRootClass
retval = mobjMyBDLL.MyBUSDLLFunction(ByVal Param1, ByVal Param2)
Is this right and if so, instead of changing the code should I rebuild my
DLL everytime I want to test it if changes have been made to it?
As you can tell, I'm very new to this. Thanks.
-
Re: Incremental testing of n-tier app
If your MyDll is a seperated project, whether included in a project group
with the UI project or installed as a ActiveX DLL component, you need have
a refenrence to MyDll in your UI project and call the function this way:
Dim mobjMyBDLL As MyBDLL.MyRootClass
Set mobjMyBDLL = New MyBDLL.MyRootClass
retval = mobjMyBDLL.MyBUSDLLFunction(Param1, Param2)
If you included the class in your UI project, then you can call the function
like this:
Dim x As MyRootClass
Set x = New MyRootClass
retval = x.MyBUSDLLFunction(Param1, Param2)
Mingyong Yang, MCP
----------------------------------------
http://www.foxinternet.net/web2/myang
"John K." <johnchulkang@hotmail.com> wrote:
>
>If I have Public functions in a "business-layer" DLL, I could just call
the
>function like this if I set a "reference" to the DLL:
>
>retval = MyBUSDLLFunction(ByVal Param1, ByVal Param2)
>
>However, if I'm not yet ready to create the DLL but want to test the app
>during development, including the "business-layer" project in the UI project
>group and setting a reference to it doesn't seem to be enough to make this
>work. I need to code it:
>
>Set mobjMyBDLL = New MyBDLL.MyRootClass
>retval = mobjMyBDLL.MyBUSDLLFunction(ByVal Param1, ByVal Param2)
>
>Is this right and if so, instead of changing the code should I rebuild my
>DLL everytime I want to test it if changes have been made to it?
>
>As you can tell, I'm very new to this. Thanks.
>
-
Re: Incremental testing of n-tier app
Thanks Mingyong. I already knew you had to set a reference to the dll but
the question you answered was whether I had to set the object reference to
the class that I wanted to call one of it's contained function.
The reason I was asking was that one of the sample app that came with a book
wasn't doing this and was wondering if there was another way.
Thanks.
"Mingyong Yang" <myang@foxinternet.net> wrote:
>
>If your MyDll is a seperated project, whether included in a project group
>with the UI project or installed as a ActiveX DLL component, you need have
>a refenrence to MyDll in your UI project and call the function this way:
>
>Dim mobjMyBDLL As MyBDLL.MyRootClass
>Set mobjMyBDLL = New MyBDLL.MyRootClass
>retval = mobjMyBDLL.MyBUSDLLFunction(Param1, Param2)
>
>If you included the class in your UI project, then you can call the function
>like this:
>
>Dim x As MyRootClass
>Set x = New MyRootClass
>retval = x.MyBUSDLLFunction(Param1, Param2)
>
>Mingyong Yang, MCP
>----------------------------------------
>http://www.foxinternet.net/web2/myang
-
Re: Incremental testing of n-tier app
John K. <johnchulkang@hotmail.com> wrote in message
news:39c29474@news.devx.com...
>
> Thanks Mingyong. I already knew you had to set a reference to the dll but
> the question you answered was whether I had to set the object reference to
> the class that I wanted to call one of it's contained function.
>
> The reason I was asking was that one of the sample app that came with a
book
> wasn't doing this and was wondering if there was another way.
the example might be doing something like:
Dim mobjMyBDLL As New MyBDLL.MyRootClass
Using "New" in the declaration causes a new instance to be created if the
variable is not set when you call it. the downside is that VB adds extra
code to all uses of the variable to ensure it is set and you can never test
"If mobjMyBDLL Is Nothing" since the very act of checking it will cause it
to be set (kind of an uncertainty principle of objects<g>)
-
Re: Incremental testing of n-tier app
No. It was using the functions found in the business-layer dll like it was
an intrinsic function so being a newbie I though I guess you could do that
'cause the function is declared public in the class.
Hum, it's even more strange since his sample app actually works. I have
to look at this again but I'm pretty sure I looked at it enough to know that
it did.
>the example might be doing something like:
>Dim mobjMyBDLL As New MyBDLL.MyRootClass
>
>
>Using "New" in the declaration causes a new instance to be created if the
>variable is not set when you call it. the downside is that VB adds extra
>code to all uses of the variable to ensure it is set and you can never test
>"If mobjMyBDLL Is Nothing" since the very act of checking it will cause
it
>to be set (kind of an uncertainty principle of objects<g>)
>
>
>
>
-
Re: Incremental testing of n-tier app
It could be that the class is Global MultiUse.
--
Mark Alexander Bertenshaw
Programmer/Analyst
PrimeResponse
Brentford
UK
"John K." <johnchulkang@hotmail.com> wrote in message
news:39c29d20$1@news.devx.com...
>
> No. It was using the functions found in the business-layer dll like it
was
> an intrinsic function so being a newbie I though I guess you could do that
> 'cause the function is declared public in the class.
>
> Hum, it's even more strange since his sample app actually works. I have
> to look at this again but I'm pretty sure I looked at it enough to know
that
> it did.
>
> >the example might be doing something like:
> >Dim mobjMyBDLL As New MyBDLL.MyRootClass
> >
> >
> >Using "New" in the declaration causes a new instance to be created if the
> >variable is not set when you call it. the downside is that VB adds extra
> >code to all uses of the variable to ensure it is set and you can never
test
> >"If mobjMyBDLL Is Nothing" since the very act of checking it will cause
> it
> >to be set (kind of an uncertainty principle of objects<g>)
> >
> >
> >
> >
>
-
Re: Incremental testing of n-tier app
Bingo Mark! Having found this out, would you consider this to be a proper
technique or do you know of any downside to this approach? TIA.
"Mark Alexander Bertenshaw" <mark.bertenshaw@virgin.net> wrote:
>It could be that the class is Global MultiUse.
>
>--
>Mark Alexander Bertenshaw
>Programmer/Analyst
>PrimeResponse
>Brentford
>UK
-
Re: Incremental testing of n-tier app
John -
I think that Global Multiuse is an incredibly useful VB "hack" that was
deliberately created so that we could have ActiveX DLLs which appeared to
behave like traditional DLLs i.e. they simply had functions that you called,
without any of this CreateObject of Set x = New Class type stuff.
IMHO this is what they are best at, and as a result these classes shouldn't
have any state, since you are not really using them as a class. I typically
use one such class per ActiveX DLL project in order to fake constructors for
my "standard classes".
For instance, if I have a class, CWotsit, which definitely absolutely must
be initialised with a Thingy value when you create it, then I make the
CWotsit class Public Not Creatable, thus making it impossible for a user to
create an instance of my CWotsit class using CreateObject or New CWotsit.
If the user wants an instance of CWotsit, he must call the following method
in the Global MultiUse class, GAccessor:
Public Function CWotsit(ByRef udtThingy As Thingy) As CWotsit
If IsValid(udtThingy) Then
Set CWotsit = New CWotsit
CWotsit.Initialise udtThingy
Else
Err.Raise 10422, "MyProject.GAccessor", "Invalid value of Thingy"
End If
End Function
(In fact I think I saw a recent posting [possibly by Matt Curland] which
suggested a similar mechanism for creating instances in C++ projects. In
this case the poster was suggesting that this was better than using
constructors since the instance is not created unless the params are
validated.)
As for downsides - the only one that I can think of is that you cannot
deliberately destroy the hidden instance of the Global MultiUse class once
it has been loaded. You would have close down the application before it is
destroyed. But if you have minimum state in the class, then this is not a
problem.
--
Mark Alexander Bertenshaw
Programmer/Analyst
PrimeResponse
Brentford
UK
"John K." <johnchulkang@hotmail.com> wrote in message
news:39c63a1c$1@news.devx.com...
>
> Bingo Mark! Having found this out, would you consider this to be a proper
> technique or do you know of any downside to this approach? TIA.
>
> "Mark Alexander Bertenshaw" <mark.bertenshaw@virgin.net> wrote:
> >It could be that the class is Global MultiUse.
> >
> >--
> >Mark Alexander Bertenshaw
> >Programmer/Analyst
> >PrimeResponse
> >Brentford
> >UK
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|