[Edu-sig] Explaining Classes and Objects

Chuck Allison chuck at freshsources.com
Tue Jun 14 05:48:24 CEST 2005


Hello Scott,

Monday, June 13, 2005, 10:16:12 AM, you wrote:

SDD> Kirby Urner wrote:
>> Based on my working with Bernie, I think it's helpful to start early with
>> the class/object distinction....
>> rectobj = Rectangle(...)
>> rectobj.setWidth(10)
>> rectobj.draw()
>> 
SDD> A useful note here: all programmers are _used_ to using objects:
SDD> The file for I/O is an OS-defined object (without the nifty syntax
SDD> in such cases).  OO provides (A) a way to define abstractions that
SDD> behave like the file abstraction yourself, and (B) a way to (at
SDD> least sometimes) define an abstaction that is "just like that other
SDD> abstraction except."  Until you have A, B doesn't make sense.  B
SDD> is hard to teach in that you need to go slowly -- the changes made
SDD> by inheritance take a while to "get."

They're used to using objects in real life, but they're not used to
having scaffolding when it's not needed. Case in point:

class Hello {
    public static void main(String[] args) {
        System.out.println("Hello");
    }
}

What's a beginner supposed to do with this Java program? What's
"public?" "static?" "void?" etc. Of course:

print 'Hello'

they can handle just fine. After a little experience with the
interpreter, they can easily pick up methods:

words = s.split()

They just grok immediately that what follows the dot pertains to
what is before it. This is a perfect lead-in to real classes.

After having taught C, C++, and Java for years, and mathematics for
decades, my 2 cents are:

1) Start with what they know from real life (numbers, simple computations, text
processing), in this sense, you begin "procedural" to some degree

2) Python is the best thing I've seen in 30 years of computing for
pedogogical and productive purposes. Only when I want speed do I see a
need for something else (I'm a C++ guy).

As I predicted last week, my current corporate teaching of Python at
Symantec is exceeding expectations. I am teaching testers, mostly with
no programming experience, Python programming. Man are we smokin'! Man
are they going fast! And they are *so* impressed. We just finished our
third 4-hour session with list comprehensions and all about
dictionaries (every method, including iterators). After modules we'll
hit classes. This has been one of the easiest and most rewarding
teaching experiences in my career. Even those who have a little Python
exposure are amazed when they see truly Pythonic solutions.

Python lets you start where people are and naturally proceed to
higher-level abstractions. But wait at least until the 4th or 5th day
before you do classes :-).

-- 
Best regards,
 Chuck



More information about the Edu-sig mailing list