Forum Moderators: coopster & phranque

Message Too Old, No Replies

A peek into the future

         

sugarkane

8:05 pm on Apr 4, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"It is my fond hope that those who are fond of Perl 5 will be fonder still of Perl 6. That being said, it's also my hope that Perl will continue trying to be all things to all people, because that's part of Perl too"

New article by Larry Wall [perl.com]

Brett_Tabke

6:54 am on Apr 6, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Interesting reading. I sure hope they don't go to insane on the object oriented stuff. I'm still trying to warm up to object oriented programming.

sugarkane

7:56 am on Apr 6, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, the nice thing about Perl5 is that the object oriented stuff is there if you want it, but you're not forced to use it. I'm slowly coming round to the idea that it's a good thing in general though, but I've a lot of old habits to break before I can go fully OO...

Xoc

11:03 am on Apr 6, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Object oriented programming (OOP) takes a different mindset than procedural programming, or even event-driven programming. I think it really took me six months after I was exposed to the features that I really got the philosophy of object oriented programming.

One of the problems with OOP is that the terminology is intimidating. In the Visual Basic courses I teach, I like the use an analogy:

Library: Box of cookie cutters
Class: Cookie cutter
Object: Cookie
Memory: Cookie dough
Instantiate: Cut a cookie with the cutter
Object Variable: a single minded 3-year old; i.e. a cookie pointer..."look, daddy, a cookie", pointing at the cookie, and can only point at one cookie at a time.

Now that is Visual Basic terminology, but other languages have similar terms. This analogy holds up pretty well and helped me understand how it all works.

The thing that took a while form me to get, is that I started by treating the objects as somewhat sophisticated structs. But as time went on, I realized that any time you want to pull information from a property to do a calculation on it, should probably be turned into a method.

Another analogy that helped:

Object: Noun (specifically a direct object)
Property: Adjective
Method: Transitive Verb

For example:

Class: Book
Object: chris pointing at a specific Book
Property: cover is black
Property: title is Emphyrio
Property: author is Jack Vance
Method: Open
Method: Read(Page 12)
Method: Close

As in

Dim chris As Book
Set chris = New Book
chris.cover = vbBlack
chris.title = "Emphyrio"
chris.author = "Jack Vance"
Call chris.Open()
Call chris.Read(Page:=12)
Call chris.Close()

which would be valid VB syntax. The Read method basically is a command that tells VB "You read the book pointed at by my 3 year old named chris (and you'll want page 12)"

Or

If chris.Title = "Emphyrio" Then

Which asks if the book that chris is pointing has a title of Emphyrio.

Edited by: Xoc

sugarkane

12:00 pm on Apr 6, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> terminology is intimidating

Definitely. I've tried several times to get started on Java or the OOP side of Perl from several books, and can't understand the English used, never mind the code. Thanks, your analogies should help.

I really want to get into this as I like the concept (as I understand it) behind it all...