Inheritance

  • Thread starter Thread starter scorpion53061
  • Start date Start date
S

scorpion53061

I am just now really starting to get into inheritance - controls, datasets,
views all that stuff and I am seeing the enormous savings in performance and
even watching the exe file size go down which is making me very happy.

I am frustrated a bit though it seems to be costing me more time in that I
am kind of not seeing the entire picture in the development environment. I
was wondering how you more experienced folks handle this ......I thought
about always writing 2 projects - one that would be able to reference
everything visually and one that is available with everything else
optimized.

Just wanted your all opinions.....
 
scorpion53061 said:
I am just now really starting to get into inheritance - controls,
datasets, views all that stuff and I am seeing the enormous savings
in performance and even watching the exe file size go down which is
making me very happy.

I am frustrated a bit though it seems to be costing me more time in
that I am kind of not seeing the entire picture in the development
environment. I was wondering how you more experienced folks handle
this ......I thought about always writing 2 projects - one that would
be able to reference everything visually and one that is available
with everything else optimized.

Just wanted your all opinions.....


Maybe I'm not one of the more experienced folks you are asking because I'm
not getting what your question is. The subject says "inheritance",
but...hmmm...where is the relation to "visually", "optimized" etc. Maybe I'm
"standing on the wire" (means: "I'm not quite with it today") ;-) Maybe I
need a personal lesson - would you please? :-)
 
Hi Scorpion,

One of the nice thing from visual.studio.net is that the borders to the
future are again shifted in new directions.

One of the nice thing from working in this business is that there is always
the challenge to do it better.

(This is not for all, there are a lot of people who wants to keep it by the
traditional way of doing it. But that has always been with inventions.)

When the borders are reached, it becomes again borrowing for a lot of us
here I think.

And more precise to your question.

If you are good, you will always see that your previous project was not that
what it could have been.

Don't change it, because than you become one of them who never end a
project.

Just a thought.

Cor
 
One of the nice thing from working in this business is that there is always
the challenge to do it better.

Tell me about it. I look at code I wrote even six months ago and I laugh at
myself.
Armin probably laughs at me still :)
If you are good, you will always see that your previous project was not that
what it could have been.

Don't change it, because than you become one of them who never end a
project.

That is true. THough the code I wrote six months ago I am not happy with,
hey it works. We will see where whidbey takes us. I hope I don't have ot
relearn everything all over again.
 
Me thinks Armin is picking on me. :)

I have been learning how to inherit things like datasets, dataviews,
controls and such between forms. The inherited control, does not appear on
the screen but I can code against it.
When the app runs though it appears.
I probably am not making any sense to you or not saying it in a way that you
would.
i will figure it out.
 
scorpion53061,
If I am reading your statement correctly.

Yes, when using OOP techniques, such as inheritance, encapsulation and
polymorphism the "entire picture" may be obscured, however I find most of
the time you don't need the "entire picture" when programming, design yes,
program no. I tend to "encapsulate" (pun intended) my thinking on just the
class that I am currently working on, and how that class is going to
interact with another class. Thinking of it on at a "class" level, I find
enables you not have to think so hard to see the "entire picture"...

Normally when I want the "entire picture" I will create a UML diagram in
Visio, using the "Project - Visio UML - Reverse Engineer" in VS.NET
(enterprise & professional?) Also I find doing my design work in UML before
I start programming to be easier in most cases.
I thought
about always writing 2 projects - one that would be able to reference
everything visually and one that is available with everything else
optimized.
I'm not following you, however this smells of a bad idea. Are you saying
writing a "procedural" program that solves the problem & also writing a OOP
program that solves the same problem? On small case by case basis this is a
good idea to learn OOP, when you come from a largely "procedural"
background, however on an ongoing basis, this is not a good idea, as you are
more then doubling your work load. Using Refactoring
(http://www.refactoring.com) you can take a largely "procedural" design and
in a disciplined way restructure your design into a OOP design.

Hope this helps
Jay
 
scorpion53061 said:
Me thinks Armin is picking on me. :)

No no! Really not. 8-)
I have been learning how to inherit things like datasets,
dataviews, controls and such between forms.

Do you mean "pass between" or "inherit from"?
The inherited control,

Ok, you mean inherited. :)
does not appear on the screen but I can code against it.

Who wins? ;-)
When the app runs though it appears.
I probably am not making any sense to you or not saying it in a way
that you would.
i will figure it out.

I think Cor and Jay can be more helpful in this matter today. :-/
 
You might be right. I think I am confusing inheritance and sharing (or pass
between like you said)
I create a class and then Import it to the form I want ot use it in.
Inheritance or sharing (or pass between?)

You are doing fine as far as help. You always have.
 
Thanks for your response Jay...

Tell me this.....
Lets say I build an app and take the code out of that app and build a new
app with the same name. I dont add any graphical objects in the designer but
all I add is the code.

Will my project size be smaller than it was? Will my performance be better
than it was?

the reason I ask is I notice when I add a graphical object in the designer
the size of my exe generated has a noticeable increase. But if I create the
item in code the increase is negligable...
 
scorpion53061 said:
Armin probably laughs at me still :)

Aah... nooooo... never...
That is true. THough the code I wrote six months ago I am not happy with,
hey it works. We will see where whidbey takes us. I hope I don't have ot
relearn everything all over again.

I once heard that every project must be written twice.
 
scorpion53061 said:
You might be right. I think I am confusing inheritance and sharing
(or pass between like you said)
I create a class and then Import it to the form I want ot use it
in. Inheritance or sharing (or pass between?)

Well, importing is again a different thing. ;-)
You are doing fine as far as help. You always have.

Thx.
 
scorpion53061,
Will my project size be smaller than it was? Will my performance be better
than it was?
Does it really matter?

I tend to prefer shortening developer time over optimizing for size or
speed. One way to shorten developer time is to favor strong OOP concepts.
VB.NET fully supports strong OOP concepts. Strong OOP concepts can shorten
both initial development along with subsequent maintenance. Of course you
may spend some extra time in design, with Refactoring and some other Extreme
Programming concepts (Unit Tests) you can "reduce" the design time some,
however I still feel you need to have a good idea of what the design should
be. Plus you and your staff may need further training.

Another way to shorten developer time is to use all the tools available in
VS.NET. For example using the Forms designer instead of using "notepad" to
code the form.

I prefer to write semantically correct (OOP) programs first, then when a
routine is proven to be slow (via profiling) I will address that routine.

Of course this also implies that you select the correct tool for the correct
job. For example: knowing when to select an untyped dataset, over a typed
dataset, over an XML document, over an actual object Domain model.

To actually answer your question, compare the code that you create with the
code that the designer creates (its in a collapsed region). I'm sure you
will find the designer sets a few more properties then you do, also the
designer stores information it will need the next time you design the form,
neither should actually amount to much. I'm sure it varies by control of how
much 'extra' stuff the designer may include...
the reason I ask is I notice when I add a graphical object in the designer
the size of my exe generated has a noticeable increase. But if I create the
item in code the increase is negligible...
By graphical object, do you mean any control, or do you specifically mean an
Image? The designer will embed your image in your executable, which is a
good thing! There is no chance of it getting lost, plus its "easier" to
internationalize. However this image will cause a significant increase in
the size of your assembly.

Hope this helps
Jay

scorpion53061 said:
Thanks for your response Jay...

Tell me this.....
Lets say I build an app and take the code out of that app and build a new
app with the same name. I dont add any graphical objects in the designer but
all I add is the code.

Will my project size be smaller than it was? Will my performance be better
than it was?

the reason I ask is I notice when I add a graphical object in the designer
the size of my exe generated has a noticeable increase. But if I create the
item in code the increase is negligable...
<<snip>>
 
Armin,
with,
I once heard that every project must be written twice.

I've heard that developers are never happy with their own work, and if they
could they would continually rewrite their own code. I know there are some
programs I have, that I really want to rewrite ;-)

Jay
 
Well I remember the first project I ever wrote.......I knew nothing of
sharing controls and inheritance. I created a new object each and every
time. .NET was my first foray into programming and I thought I had done
good.

Well to make a long story short the compiled exe size was like 1.3
megabytes. Then I saw some apps around the net whose exe files were like
80kb and yet did everything I was doing. I knew something was really wrong
with the way I was doing things.

The thing was the performance of the program people at work seemed pleased
with it though I was dying to take the project back before anyone who knew
what I was doing and had experience in this area and saw right through me.

So this is why I was asking. I understand the need ot develop faster. Just
got to find that middle of the road I guess. I am finding doing this without
the designer to be dreadfully slow so I will go back and rethink this.
 
scorpion53061
Well I remember the first project I ever wrote.......I knew nothing of
sharing controls and inheritance. I created a new object each and every
time. .NET was my first foray into programming and I thought I had done
good.
Creating a new object is different then defining a new class. Do you mean
defining a new class?

For one can define a class and create a single object from it, or one could
create thousands of objects from it. However only defined one class was
defined.
So this is why I was asking. I understand the need ot develop faster. Just
got to find that middle of the road I guess. I am finding doing this without
the designer to be dreadfully slow so I will go back and rethink this.
You can still use the designer and leverage OOP. For example if each of your
forms have the "same" tool bar, you can define a base form that has the tool
bar, then you can derive each of your forms from this base form. Compare
this to cutting & pasting the same tool bar into each of your forms. At run
time each instance of the distinct forms will have their own instance of the
toolbar, however in your source the tool bar will only be defined in the
base class. Hence if you need to add a button, you add it to the base class
& all the derived classes will automatically inherit it.

If you handle the same event on every one of your TextBox controls, I find
its easier to derive from TextBox control, and add the event handler to this
new extended TextBox, plus any supporting properties. Then I use this new
extended TextBox control on my forms

Once you become more accustomed to OOP you will find there is "general" code
that you can move into your base class that does distinct things, based on
"Template Methods" from your derived classes. See Joe Fallon's question
titled "Inheritance Question" from 2 Dec.

Hope this helps
Jay
 
Back
Top