By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,960 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,960 IT Pros & Developers. It's quick & easy.

vb.net and OOP (inheritance)

P: n/a

--
hello

If I inherit an object say Car() with my new class SportsCar(). Does vb.net
creates space in memory for the object SportsCar() and associated space for
Car().

So in effect you are creating space for 2 Objects with all its
properties/methods.

If you only ever use say half the inherited class -methods/properties, are
you actually being inefficient with memory space. With the trade off being a
more OOP design....

Is the use of Inheritance a possible overhead with system space. As in the
case above.

thanks
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
John,

The only advice I can give you at the moment is, don't worry about this at
the moment. When you are a little bit further you learn what objects are
created and how. Now it will be only confusing and makes that you don't go
in the right direction.

However to tell something. There are as much objects created on the managed
heap as often that you tell.

Private(or whatever) John as New Andrew.

Private(or whatever) John as Andrew, creates only an empty place to set the
reference (address) to the next John you create from Andrew

When you look at the control classes , you will see that they inherrit every
time up with in the top Object.

I hope this helps?

Cor

"john andrew" <jo********@discussions.microsoft.com>

--
hello

If I inherit an object say Car() with my new class SportsCar(). Does
vb.net
creates space in memory for the object SportsCar() and associated space
for
Car().

So in effect you are creating space for 2 Objects with all its
properties/methods.

If you only ever use say half the inherited class -methods/properties, are
you actually being inefficient with memory space. With the trade off being
a
more OOP design....

Is the use of Inheritance a possible overhead with system space. As in the
case above.

thanks

Nov 21 '05 #2

P: n/a
Hi

Well I can do a fair bit with .Net already eg build classes, use controls
similiar to VB6...not everthing though but I take your point. VB.net isnt
that daunting since I have C/Java background but it will take time to be
effective in.

"Cor Ligthert" wrote:
John,

The only advice I can give you at the moment is, don't worry about this at
the moment. When you are a little bit further you learn what objects are
created and how. Now it will be only confusing and makes that you don't go
in the right direction.

However to tell something. There are as much objects created on the managed
heap as often that you tell.

Private(or whatever) John as New Andrew.

Private(or whatever) John as Andrew, creates only an empty place to set the
reference (address) to the next John you create from Andrew

When you look at the control classes , you will see that they inherrit every
time up with in the top Object.

I hope this helps?

Cor

"john andrew" <jo********@discussions.microsoft.com>

--
hello

If I inherit an object say Car() with my new class SportsCar(). Does
vb.net
creates space in memory for the object SportsCar() and associated space
for
Car().

So in effect you are creating space for 2 Objects with all its
properties/methods.

If you only ever use say half the inherited class -methods/properties, are
you actually being inefficient with memory space. With the trade off being
a
more OOP design....

Is the use of Inheritance a possible overhead with system space. As in the
case above.

thanks


Nov 21 '05 #3

P: n/a
A common misconception for people new to oop is that the code in a class
takes up space in the memory on a per-instance basis. This is not correct.

When a class is instantiated a structure containing its internal fields and
a list of adresses for it's virtual or overridable methods is created. If a
class has say one integer field and no virtual methods the class will occupy
about four bytes of heap space even if the methods of the class require a
million lines of code to manipulate that integer. Each instance of the class
shares the physical bytes of code in memory with all the others and the
instance of the *data* for each class is referenced through the "Me"
reference ("this" in C#)

A rough example will be that Class A has 1024 bytes of code for it's methods
plus say 100 bytes for its fields, virtual method table and Me reference.
The code for A is already loaded because its program, not data but you can
consider that it takes 1124 bytes of physical memory for one instance. Two
instances however are 1224 bytes and three instances are 1324 bytes.

I hope this explanation answers your question.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"john andrew" <jo********@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...

--
hello

If I inherit an object say Car() with my new class SportsCar(). Does vb.net creates space in memory for the object SportsCar() and associated space for Car().

So in effect you are creating space for 2 Objects with all its
properties/methods.

If you only ever use say half the inherited class -methods/properties, are
you actually being inefficient with memory space. With the trade off being a more OOP design....

Is the use of Inheritance a possible overhead with system space. As in the
case above.

thanks

Nov 21 '05 #4

P: n/a
Get you any simple answer. Think why Microsoft support fill OO in VS.NET.

chanmm

"john andrew" <jo********@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...

--
hello

If I inherit an object say Car() with my new class SportsCar(). Does
vb.net
creates space in memory for the object SportsCar() and associated space
for
Car().

So in effect you are creating space for 2 Objects with all its
properties/methods.

If you only ever use say half the inherited class -methods/properties, are
you actually being inefficient with memory space. With the trade off being
a
more OOP design....

Is the use of Inheritance a possible overhead with system space. As in the
case above.

thanks

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.