PDA

View Full Version : Parameters and lists


jmadar
03-29-2006, 02:29 PM
Hi all,

We are planning to use Alice in our introductory programming course. After playing with Alice for a bit (and reading the textbook), I have the following observations:

1) As far as I can tell, you can only pass objects around as generic object types. This means it is impossible for me to call a custom method once an object is passed around.

2) The same idea for objects in a lists. Since we can only have generic object types in a list, I cannot call a custom method for any objects in a list.

3) Type casting does not exist within Alice.

I believe this puts a very big limitation on the way we teach OO programming. In OO, you try to designate responsibilies according to the purpose of each class (information hiding). For example, I would like to create a class "Target" that has a method called "hit()". The hit() method would be called by the collision detection routine and perform some action when it is hit by the player.

The collision detection code can then be very clean. We can simply traverse the list of targets and call its hit() method as follows:

function detect_collision(list target_list)
{
foreach (target_list as target) {
if (player is close to target) {
((Target) target).hit();
}
}
}

Please correct me if I'm wrong, but I don't think you can do this in Alice.

Thanks

Jason

gabe
03-31-2006, 11:51 AM
This is correct, and is a known limitation in Alice we are ... "not proud of."

Alice v3.0 will address this nicely, as it will use the underlying Java object and type mechanisms.

BenMcLean
10-19-2009, 03:46 PM
This is correct, and is a known limitation in Alice we are ... "not proud of."

Alice v3.0 will address this nicely, as it will use the underlying Java object and type mechanisms.Hooray