Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: OOD and Visual Basic


Message #1 by "Mark Phillips" <mark@p...> on Mon, 19 Aug 2002 19:53:13
Mark,

You can certainly do a Singleton implementation of a class in VB 6.  In
terms of penalty of creating lots of instances of a class, of course
there is, because additional memory is required to do this, but I think
that it's substantial.  Creating pool-able objects (MTS/COM+) in VB is
not possible because of the apartment nature of the COM servers that VB
can only produce.  You can force pooling by hacking and setting up
attributes in the registry, but this is not recommended, and if you are
not careful, you can cause havoc in the system...

The disadvantage of creating a singleton implementation is the
possibility of corrupting the single instance of the object and having
to restart the server all together...

Hope this help you...

Poch

-----Original Message-----
From: Richard Ainsley [mailto:rainsley@p...] 
Sent: Tuesday, August 20, 2002 2:21 PM
To: professional vb
Subject: [pro_vb] Re: OOD and Visual Basic

Mark,

I don't use JAVA so I can't judge how that works.  But, your concept of
how
VB works is in error.  There is a penalty for pre-VB.NET only if you
have
discarded the last instance of an object.  In VB.NET objects stay around
after you are done with them until a garbage collector destroys them,
and
will be reused automatically if still around.  If you have already
instanciated an object elsewhere, then the procedureal portions of the
class
are already in memory and all that happens is that the required memory
is
allocated for the new object's data.  Free threading is not supported
until
VB.NET, if that is your real concern (Same data and same code, multiple
processes share).  However, apartment style threading was supported
(shared
code, separate data).

If you code a loop within which you create then discard the same object,
it
makes little difference what your language is, that is an inefficient
design.  If you are creating a thousand objects because you really need
to
represent 1000 different objects at the same time, I dare to claim that
even
you in Java will need to create 1000 objects.

The "Code modules" you refer to are "Standard Modules" I assume.  VB.NET
dropped the concept.  They essentially are global variable and procedure
containers, and their memory handling differs some.  Nothing says you
need
to have a standard module.  Code modules are essentially form modules
without the GUI stuff.  If you are uncomfortable using Standard modules,
don't.


----- Original Message -----
From: "Mark Phillips" <mark@p...>
To: "professional vb" <pro_vb@p...>
Sent: Monday, August 19, 2002 12:53 PM
Subject: [pro_vb] OOD and Visual Basic


> I just finished reading Peter Wright's " Beginning Visual Basic 6
Objects"
> and I have a question for all you VB experts. You should know that I
am
> really a Java OOP and my current project is my first foray into VB. I
am
> using VB 6 for a variety of client reasons, so no fair bringing up
.Net!
>
> Peter suggests the use of code modules as the "glue" between the
Business
> Object and the UI. In his "3 tier model" he usese a UI Tier, a User
> Services Tier, a Business Services Tier, and a Data Services Tier. I
am
> addressing the User Services Tier. Each of these code modules
corresponds
> to a use case for the application. Now, code modules are a neat trick
in
> VB, but other languages (like Java) don't have them. Are there other
> object oriented models in VB that don't use code modules? I find the
> notion of code fragments floating around the application as odd.
>
> Also, in his examples, he creates lots of instances of classes,
instead of
> creating either an object pool, or just one instance of the class and
> resung that instance. For example, whenever the application wants to
> access the DB, itcreates a new instance of the class that connects to
the
> DB, instead of creating one instance and passing it around, or using
an
> object pool. There is a performance penalty in Java for creating lots
of
> instances of classes - is the penalty in VB so small that one does not
> need object pools or other forms of resouce sharing?
>
> Thanks for your comments?
>
> Mark Phillips
>
> ---
> Visual C# - A Guide for VB6 Developers
> This book will make it easy to transfer your skills
> from Visual Basic 6 to C#, the language of choice
> of the .NET Framework.
> http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059
>



---
Visual C# - A Guide for VB6 Developers
This book will make it easy to transfer your skills 
from Visual Basic 6 to C#, the language of choice 
of the .NET Framework.
http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059



  Return to Index