PC Review


Reply
Thread Tools Rate Thread

Re: LinkLists Equivilant

 
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      19th Nov 2003
Sueffel,
> Is there an equiv system to C++'s LinkList, or VB6's CallByName?

What does a Linked List in C++ have to do with VB6's CallByName?

Or do you mean something other then Linked List by the phrase LinkList?

..NET offers two "Linked List" type collections. HybridDictionary &
ListDictionary both in the System.Collections.Specialized namespace.

VB.NET has a CallByName just like VB6.

> And is this something that can be used in a whatever plug-in
> architecture VB.NET supports, Late-binding is preferred.

You can use System.Activator.CreateInstance to load & create objects
dynamically.

Hope this helps
Jay

"Sueffel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is there an equiv system to C++'s LinkList, or VB6's CallByName? Could

there be examples provided? And is this something that can be used in a
whatever plug-in architecture VB.NET supports, Late-binding is preferred.
>
> --
> Thank You
> Sueffel
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003
>



 
Reply With Quote
 
 
 
 
Sueffel
Guest
Posts: n/a
 
      20th Nov 2003

"Jay B. Harlow [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Sueffel,
> > Is there an equiv system to C++'s LinkList, or VB6's CallByName?

> What does a Linked List in C++ have to do with VB6's CallByName?
>
> Or do you mean something other then Linked List by the phrase LinkList?
>
> .NET offers two "Linked List" type collections. HybridDictionary &
> ListDictionary both in the System.Collections.Specialized namespace.
>
> VB.NET has a CallByName just like VB6.
>
> > And is this something that can be used in a whatever plug-in
> > architecture VB.NET supports, Late-binding is preferred.

> You can use System.Activator.CreateInstance to load & create objects
> dynamically.
>
> Hope this helps
> Jay
>
> "Sueffel" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Is there an equiv system to C++'s LinkList, or VB6's CallByName? Could

> there be examples provided? And is this something that can be used in a
> whatever plug-in architecture VB.NET supports, Late-binding is preferred.
> >
> > --
> > Thank You
> > Sueffel
> >
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003
> >

>
>

Well, I'm actually hoping to get away from the CallByName stuff. It works,
but isn't the easiest to manage. I have about 500 functions I currently use
in CallByName, and would like to get away from it. Was thinking about
moving it to Scripting Run-time, but the limitations on VBScript, and all
the text files... Hmmm...

Thanks Again
Sueffel


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003


 
Reply With Quote
 
 
 
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      20th Nov 2003
Sueffel,
Both VB6 & VB.NET support Late Binding, why not "Just Do It" to borrow a
phase from a popular company.

Option Strict Off

Dim obj As Object

obj.DoSomething()
obj.DoSomethingElse()

I'm not seeing what the problem here is. If you have Option Strict Off,
VB.NET fully supports Late Binding.

VB6 also Supports Late Binding without using CallByName.

CallByName allows you to call the methods, when you have Option Strict On.

Rather then use either Late Binding (via Option Strict Off) or CallByName,
have you considered defining an Interface and use Early Binding? Your
programs will execute faster, as you will have less runtime checks for
incorrect parameters, as it was all done at compile time.

Hope this helps
Jay


"Sueffel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Jay B. Harlow [MVP - Outlook]" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > Sueffel,
> > > Is there an equiv system to C++'s LinkList, or VB6's CallByName?

> > What does a Linked List in C++ have to do with VB6's CallByName?
> >
> > Or do you mean something other then Linked List by the phrase LinkList?
> >
> > .NET offers two "Linked List" type collections. HybridDictionary &
> > ListDictionary both in the System.Collections.Specialized namespace.
> >
> > VB.NET has a CallByName just like VB6.
> >
> > > And is this something that can be used in a whatever plug-in
> > > architecture VB.NET supports, Late-binding is preferred.

> > You can use System.Activator.CreateInstance to load & create objects
> > dynamically.
> >
> > Hope this helps
> > Jay
> >
> > "Sueffel" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Is there an equiv system to C++'s LinkList, or VB6's CallByName?

Could
> > there be examples provided? And is this something that can be used in a
> > whatever plug-in architecture VB.NET supports, Late-binding is

preferred.
> > >
> > > --
> > > Thank You
> > > Sueffel
> > >
> > >
> > > ---
> > > Outgoing mail is certified Virus Free.
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003
> > >

> >
> >

> Well, I'm actually hoping to get away from the CallByName stuff. It

works,
> but isn't the easiest to manage. I have about 500 functions I currently

use
> in CallByName, and would like to get away from it. Was thinking about
> moving it to Scripting Run-time, but the limitations on VBScript, and all
> the text files... Hmmm...
>
> Thanks Again
> Sueffel
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003
>
>



 
Reply With Quote
 
Sueffel
Guest
Posts: n/a
 
      20th Nov 2003

"Jay B. Harlow [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Sueffel,
> Both VB6 & VB.NET support Late Binding, why not "Just Do It" to borrow a
> phase from a popular company.
>
> Option Strict Off
>
> Dim obj As Object
>
> obj.DoSomething()
> obj.DoSomethingElse()
>
> I'm not seeing what the problem here is. If you have Option Strict Off,
> VB.NET fully supports Late Binding.
>
> VB6 also Supports Late Binding without using CallByName.
>
> CallByName allows you to call the methods, when you have Option Strict On.
>
> Rather then use either Late Binding (via Option Strict Off) or CallByName,
> have you considered defining an Interface and use Early Binding? Your
> programs will execute faster, as you will have less runtime checks for
> incorrect parameters, as it was all done at compile time.
>
> Hope this helps
> Jay
>
>

<SNIP>
Early binding? Now that sounds interesting. Will have to look into how to
do Interfaces and see if I can find more about that.

Thanks for the tip Jay,
Sueffel



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003


 
Reply With Quote
 
Sueffel
Guest
Posts: n/a
 
      20th Nov 2003

"Jay B. Harlow [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
<SNIP>

Well, it looks like I can't use Early-binding in this case, although
once I saw someone refer to it as strong-typing, I knew what the game was
then. The reason I don't believe I can use early-binding is the methods are
in a DLL, and I have no clue as to what the calsses will be called until I
get the listing out of the dll of what commands are in there. Sounds
confusing. But, let me try it from this approach.

For example: The main assembly is a game, the DLL is all the commands
this game supports. So at the time I design the game, I don't know what
commands the game will support, just that they will be there. This is why I
would need the CallByName functionality in VB6, although the plugin system
I'm using now I like.

What I've done as a workaround is the CreateInstance method, which takes
a string argument for the class name, and use Namespaces to group things,
and made a system that is pluggable, and also I don't have to really care
what the command is or what it does, just that it may or may not exists.
All the testing seems to point to this conclusion.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003


 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      20th Nov 2003
Sueffel,
Yes you can use Early-binding (Strong-typing)! Note what I am describing can
be done in both VB.NET & VB6!

Do you have a single class that has multiple commands or is each command its
own class?

I normally would make each command its own class, as its easier. Also its
the Command Pattern one of the GOF Design Patterns.

I define an interface that represents a Command (or Plugin or other item I
am dynamically loading).

Public Interface ICommand
Sub Execute()
' other useful methods & properties that a command may have.
End Interface

I would have at least 3 assemblies.
- The main executable
- A DLL that defines my ICommand interface (referenced by all the other
assemblies)
- One or more DLLs that contain one or more classes each that implement
ICommand

The Main executable only uses ICommand variables, while the dlls offer
actual implementation of various commands.

Then using CreateInstance, as you have, you load each class, seeing as the
class implements ICommand you get early-binding! you simply assign the
object loaded into a variable of type ICommand and call methods of the
ICommand interface.

Having multiple commands per class complicates matters as you then need to
implement more of a ICommandCollection interface, where you can pass the
name of the command that the object can execute, Plus possibly some method
of returning the list of commands that the class supports. I would consider
having using Delegates in the multiple command per object case...

Hope this helps
Jay

"Sueffel" <(E-Mail Removed)> wrote in message
news:%23ng4V$(E-Mail Removed)...
>
> "Jay B. Harlow [MVP - Outlook]" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> <SNIP>
>
> Well, it looks like I can't use Early-binding in this case, although
> once I saw someone refer to it as strong-typing, I knew what the game was
> then. The reason I don't believe I can use early-binding is the methods

are
> in a DLL, and I have no clue as to what the calsses will be called until I
> get the listing out of the dll of what commands are in there. Sounds
> confusing. But, let me try it from this approach.
>
> For example: The main assembly is a game, the DLL is all the commands
> this game supports. So at the time I design the game, I don't know what
> commands the game will support, just that they will be there. This is why

I
> would need the CallByName functionality in VB6, although the plugin system
> I'm using now I like.
>
> What I've done as a workaround is the CreateInstance method, which

takes
> a string argument for the class name, and use Namespaces to group things,
> and made a system that is pluggable, and also I don't have to really care
> what the command is or what it does, just that it may or may not exists.
> All the testing seems to point to this conclusion.
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003
>
>



 
Reply With Quote
 
Sueffel
Guest
Posts: n/a
 
      20th Nov 2003

"Jay B. Harlow [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
<SNIP>
Nope, each command is it's own class, along with any support system it
may need, including variables, structures, etc.
I have seen what you are discussing about the interfaces, but I couldn't
get it to work with a string variable that defines what command to run. So,
I would need something that could use this:

Dim InputStr as String

InputStr=TextBox1.Text 'Defines the command name, or in my case, the name of
the class

In every class, I have the one public function, Execute, which always
returns something. I know that every time it will return the same datatype,
such as String, but what I'm hoping to achieve is a level of dynamics of
returning any datatype and being able to account for it without ever knowing
what the command may return. I'm thinking of just using an Object datatype
and being done with it. In the model I'm working with, I have two
overloaded functions that contain the CreateInstance method, one for
arguments, one without. The biggest concern I have is, I'm only developing
the app, and a template for the command system, other developers will
actually be developing the commands seperatly. It's a bit of a delemma. I
will look more into Interfaces though, I will not overlook any suggestions
at this point in time.

Thank you again Jay,
Sueffel


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003


 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      20th Nov 2003
On 2003-11-20, Sueffel <(E-Mail Removed)> wrote:
>
> "Jay B. Harlow [MVP - Outlook]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
><SNIP>
> Nope, each command is it's own class, along with any support system it
> may need, including variables, structures, etc.
> I have seen what you are discussing about the interfaces, but I couldn't
> get it to work with a string variable that defines what command to run. So,
> I would need something that could use this:
>
> Dim InputStr as String
>
> InputStr=TextBox1.Text 'Defines the command name, or in my case, the name of
> the class
>
> In every class, I have the one public function, Execute, which always
> returns something. I know that every time it will return the same datatype,
> such as String, but what I'm hoping to achieve is a level of dynamics of
> returning any datatype and being able to account for it without ever knowing
> what the command may return. I'm thinking of just using an Object datatype
> and being done with it. In the model I'm working with, I have two
> overloaded functions that contain the CreateInstance method, one for
> arguments, one without. The biggest concern I have is, I'm only developing
> the app, and a template for the command system, other developers will
> actually be developing the commands seperatly. It's a bit of a delemma. I
> will look more into Interfaces though, I will not overlook any suggestions
> at this point in time.
>
> Thank you again Jay,
> Sueffel
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003
>
>


If I'm understanding you correctly, then you may seriously want to
look into reflection.

--
Tom Shelton
[MVP - Visual Basic]
 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      20th Nov 2003
Sueffel,
Are the arguments to the constructor of the class or to the Execute method?

Normally when dealing with dynamically loaded types you need to be
consistent on the parameters expected by the constructors. Some do some
don't can lead to problems, in that how does you program know how many
parameters to pass to the constructor?

Also the Execute method should have a fixed set of parameters for the same
reason, however you could define the Execute method to accept a ParamArray
of strings, which would allow a 'varying number of parameters'.

> In every class, I have the one public function, Execute, which always
> returns something.

In which case each of your classes would implement the ICommand interface,
along with the Execute method.

' framework.dll
Public Interface ICommand
Function Execute(ParamArray args() As String) As Object
End Interface

' simple command.dll
' references framework.dll
Public Class SimpleCommand
Implements ICommand

Function Execute(ParamArray args() As String) _
As Object Implements ICommand.Execute
End Function

End Class

' main executable.exe
' references framework.dll only

Public Sub Main()
' Full type name of one command class
Dim typeString As String = "Simple.SimpleCommand, Simple"
' This is the parameter to the contructor of a comment
Dim param As String = "constructor parameters"
Dim t As Type
t = Type.GetType(typeString)
Dim value As Object
value = Activator.CreateInstance(t, New Object() {param})
Dim command As ICommand

command = DirectCast(value, ICommand)
command.Execute(arg1, arg2)
End Sub

> The biggest concern I have is, I'm only developing
> the app, and a template for the command system, other developers will
> actually be developing the commands separately. It's a bit of a delemma.

I
> will look more into Interfaces though, I will not overlook any suggestions
> at this point in time.

That's all the more reason to define an interface, the Interface tells the
other developers that this is what the HAVE to do, if they don't your
program won't deal with them.

Hope this helps
Jay


"Sueffel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Jay B. Harlow [MVP - Outlook]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> <SNIP>
> Nope, each command is it's own class, along with any support system it
> may need, including variables, structures, etc.
> I have seen what you are discussing about the interfaces, but I

couldn't
> get it to work with a string variable that defines what command to run.

So,
> I would need something that could use this:
>
> Dim InputStr as String
>
> InputStr=TextBox1.Text 'Defines the command name, or in my case, the name

of
> the class
>
> In every class, I have the one public function, Execute, which always
> returns something. I know that every time it will return the same

datatype,
> such as String, but what I'm hoping to achieve is a level of dynamics of
> returning any datatype and being able to account for it without ever

knowing
> what the command may return. I'm thinking of just using an Object

datatype
> and being done with it. In the model I'm working with, I have two
> overloaded functions that contain the CreateInstance method, one for
> arguments, one without. The biggest concern I have is, I'm only

developing
> the app, and a template for the command system, other developers will
> actually be developing the commands seperatly. It's a bit of a delemma.

I
> will look more into Interfaces though, I will not overlook any suggestions
> at this point in time.
>
> Thank you again Jay,
> Sueffel
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003
>
>



 
Reply With Quote
 
Sueffel
Guest
Posts: n/a
 
      21st Nov 2003

"Jay B. Harlow [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sueffel,

<SNIP>
I have no arguments passed to the constructor, and the Execute function
accepts one argument, but the Array thing is a pretty nice idea. Also, I
must use late-binding. The reason is I'm going to emulate the CopyOver
function of *nix OS's. Under *nix, the binary is loaded and ran from
memory, so the binary can be updated on the fly. What CopyOver does is
re-attach the In-memory binary to the disk binary, then essently reloads it.
The nifty thing about this is the program never stops running, never loses
one variable state, and enables on-the-fly updating. With Early-binding,
the DLL is attached all throughout the run-time, where as Late-binding the
DLL only is "in use" for as long as the CreateMethod/Execute methods are
actually executing. So, without killing the MainApp, I can, on-the-fly,
copy a new DLL into the Directory, and essently create a CopyOver system. I
do see the advantages of Early-binding though, don't get me wrong on that
Jay, and the advice and pointers are truely appreciated, and I may also use
Early-binding on another point in the system where I don't want the DLL to
be able to be updated on the fly.

Thank you again for all your help,
Suefell


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp.net equivilant to good old include files Simon Harris Microsoft ASP .NET 15 24th Mar 2005 12:46 PM
SDK equivilant questions raffelm Microsoft C# .NET 2 9th Feb 2004 11:46 AM
Re: LinkLists Equivilant Herfried K. Wagner [MVP] Microsoft VB .NET 0 19th Nov 2003 09:36 PM
Re: LinkLists Equivilant David Williams Microsoft VB .NET 1 19th Nov 2003 09:24 PM
Re: Porting Question: java.util.Map equivilant? Joseph Heck Microsoft C# .NET 0 18th Jul 2003 05:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:06 AM.