Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
teaching OO design / send non-primitive message / writing functions
Old
Maggie
Guest
 
Status:
Posts: n/a
Default teaching OO design / send non-primitive message / writing functions - 09-14-2007, 12:05 PM

I figured out a solution to my previous problem. You can set a variable to the top object in the list, then remove the object from the list. So this is a kludgy way of pulling an item off a list to send a message to.

Here's my problem: how do I send that object a non-primitive message?

It seems that when it comes to programmer-defined methods, you can only send one if you know the actual object you're going to send it to. For example, I can say "hanoiTower1.push," if I've written a push, but I can't send the "push" message to whichever tower I'm standing in front of if I happen to store that in an "object" variable -- I can't figure out if there's a way to be more specific than "object" (e.g. variable type= hanoiTower, not object) or to "cast" that object variable.

Having variables uncastable and confined to being a root "object" type makes it very difficult to create OO designs.

So I'm feeling very panicky about how I'm going to teach design to my students. I really don't have a sense of it. It's definitely not OO. The examples in the two texts I've read imply that it's OO and skirt around these issues. What paradigm should I be following?

Oh, and I'm having trouble with functions. It seems you can't use the regular list functionality within a function. (e.g. list.remove item from position) So, when I was writing my "pop" method, for example, I couldn't actually remove the item from the list in that function. I also couldn't copy/paste that command from a method, where I *was* allowed to access the normal list functionality. Is there a reason that functions can't do anything with a list variable? This is odd. You also don't have the "do in order" construct when creating a function.

Any advice is greatly appreciated!

Thanks,
Maggie
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.