Help requested for an old Fortran programmer

Help requested for an old Fortran programmer

Anonymous
Not applicable
348 Views
7 Replies
Message 1 of 8

Help requested for an old Fortran programmer

Anonymous
Not applicable
Greetings all!

I'm new to this world of "Visual, Object Oriented" languages. As a
programmer with over 25 years in structured, procedural and old-fashioned
languages, getting my head around some of these concepts is a difficult
proposition. I'm sure that there are others out there that have been through
this same learning experience / mind block as I am now in.

My question is this: What was is, exactly, that made the "visual, object
oriented" light come on for you? I know from previous experience learning
new languages, that as soon as that shade is removed, I'll smack myself and
say, "Why didn't I see that before". A kick start is what I'm lookin' for.

Thanks in advance for your assistance with helping this old dog with old
tricks learn new some ones.

Eric
0 Likes
349 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Eric,

This guys book will show you all the light you need to program AutoCAD VBA.

http://www.amazon.com/exec/obidos/ASIN/B00005YU70/qid%3D1012252798/sr%3D8-1/ref%3Dsr%5F8%5F7%5F1/102-9317335-3119330
0 Likes
Message 3 of 8

Anonymous
Not applicable
Eric...
Some things that have helped me (not that I'm great with object-oriented
programming (OOP) myself)

1) Finding simple examples of objects. For example, the "bicycle" example
at Sun's Java site:
http://java.sun.com/docs/books/tutorial/java/concepts/index.html
After reading a few things like this, I find myself mentally turning
real-world items into objects...

Ruler on my desk could be a Ruler object...
Would need Properties: MadeOf (wood), Units (in), SmallestDivision
(1/16), Length (12), Owner (me), 3dLocation (x,y,z), 3dRotation (x,y,z).....
etc
The MadeOf property would itself point to another object, of type
"Material". The properties of this object would include Density, Color,
Strength, Stiffness, etc...

2) Objects are like global, static, user-defined types. In this case, when
I make a new Ruler object, it's like there's a UDT floating in space
somewhere that I can query (What Units was this Ruler in, again???) I can
have 4 variables pointing to this same Ruler object, and each can query and
change the Ruler. So object variables are pointers, in that they're
references, and the variable can be deleted without deleting the Ruler that
it was pointing to.

' New keyword means there's now another Ruler data type, floating in
space and holding its own properties
Set a = New Ruler 'Set is used by VB when assigning object variables,
OOP purists frown on VB for this requirement
Set b = a ' two pointers now, to same object
Set a = Nothing 'break the link between variable A and the Ruler...
but the Ruler object is still floating in space

I realize I'm basically regurgitating (and maybe butchering) stuff you could
find at the Sun site or in Joe's book... but there's no better way to see if
I know any of this stuff than trying to explain it, right?

Hope this helps. If you have any more questions, I love talking about this
stuff...


James
0 Likes
Message 4 of 8

Anonymous
Not applicable
Eric,

A class is definition of a potential object. A class definition may contain code and data [methods and properties in OOP speak].

An object is the instantiation of a class definition. What is that? It's basically the act of creating a variable with the class definition as the data type.

Methods: these are functions that control the behavior of an object [i.e. a Move method would move the object].

Properties: this is data that controls the characteristics of an object [i.e. the Color property would set the color of the object].

For example:
AutoCAD has a Line class definition. It contains a number of methods and properties that you can easily manipulate to your liking. Here is an example of how you would create a line object in AutoCAD VBA.

Public Sub DrawLine()
Dim oLine As AcadLine
Dim StartPoint(0 To 2) As Double
Dim EndPoint(0 To 2) As Double

StartPoint(0) = 0: StartPoint(1) = 0: StartPoint(2) = 0
EndPoint(0) = 1: EndPoint(1) = 1: EndPoint(2) = 0

Set oLine = ThisDrawing.ModelSpace.AddLine(StartPoint, EndPoint)
'change it's color to blue
oLine.Color = acBlue
End Sub


Joe
--
0 Likes
Message 5 of 8

Anonymous
Not applicable
I personally never "got it" until I started using languages other than VB.
Even then the wheels didn't really start turning until I oiled them with a
book or two on OO design. Right now I'm on the hut for a good patterns
book...anybody read anything worthwhile?
--
Bobby C. Jones
www.AcadX.com
0 Likes
Message 6 of 8

Anonymous
Not applicable
Eric,



I can't claim your experience, but I had been using third-generation languages (including Fortran) for 7 years before I discovered VB 3.0 in 1993, so I can claim to have a foot in both camps. The good news is that everything you've learned still applies - procedures still call procedures, block-structures work as good as always, and anybody can make a "bad" program by plastering it with GOTO statements.



Others have given a good explanation of objects and properties, but something I wanted to add is the concept of "Events". This was something that took me personally some time to grasp as it was so foreign to the 3GL's. An Event is something that can occur (hence the name) in your computing environment, and these events can have code attached to them. For example opening a document, clicking a button, pressing a Function key may all trigger events. I say "may" because it is the developer of the object in question who determines what events are exposed, as is the case with Properties and Methods. So for example with the Document object, Autodesk has chosen to make an "ObjectModified" event available that is triggered when an object in the drawing has been modified. You could put your own code in that event to (say) change the background color as a visual cue to the user that the document has been modified.



The consequence of these Events (and the bit I took a while to grasp) is that this can lead to multiple independent pieces of code executing at the same time! For example you might have a tiny form with a stopwatch ticking over how long you've been working on the current drawing for billing purposes. This stopwatch would be running from a timer event, but simultaneously you would have other code responding to keypresses and button clicks. So although the flow of code you're used to with 3GL's still applies, it only applies in the localised procedures or Events.



Regards



Wayne Ivory

IT Analyst Programmer

Wespine Industries Pty Ltd
0 Likes
Message 7 of 8

Anonymous
Not applicable
I forgot to add (for the purists) that code in different Events is not technically occurring at the same time because the CPU is really time-slicing, but from the point of view of we humans it's running simultaneously.



(And then for the even *purer* purists, it could be running at the same time if you had parallel processors, but that's another story.)



Regards



Wayne
0 Likes
Message 8 of 8

Anonymous
Not applicable
Thanks to all who've contributed bits and pieces to further my understanding
of Object Oriented / VBA programming.
0 Likes