[Tutor] Python information

Rob rob@uselesspython.com
Thu, 1 Aug 2002 22:22:57 -0500


OOP does seem to be an interesting situation. We think in objects all day
long, and yet when it comes time to program along the same lines, struggle
seems common.

Perhaps we should put our collective heads together and create a Python
equivalent to Robocode, which is designed to teach OOP in Java by having you
program battling robot tanks.

Let's say you want to write a "Dungeons & Dragons"-type game. You know
you'll need it to have certain things (objects). You make a list of some of
them:

-monsters
-dungeons
-non-player characters
-player characters
-weapons
-treasure
-equipment
-etc.

Some of these can be lumped into more general categories. For instance,
non-player characters and player characters can both fall under the category
(class), which can just be called "character". All characters can possess
certain characteristics in common, such as:

-amount of damage that may be survived
-height
-weight
-name
-species
-vocation
-inventory
-etc.

The process goes on and on, really. The idea is to think of what kind of
objects you will want/need in your program, create classes for these
objects, and then create instances of these classes. A class instance can be
"Banglor the Elf", a specific instance of class character.

Objects have two general things the programmer needs to fuss over:
attributes and behavior. Attributes can be the character's name, hair color,
fondness for dirty poetry, etc. and behaviors can be throwing spears,
running, singing, sleeping, and stopping going forward when bumping into
walls.

Does any of this sort of discussion help at all?

Rob (who should really be studying for tomorrow's C++ final ;-)
http://uselesspython.com

> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Christian Wyglendowski
> Sent: Thursday, August 01, 2002 4:59 PM
> To: tutor@python.org
> Subject: Re: [Tutor] Python information
>
>
> >>> Isaac Hall <hall@nhn.ou.edu> 07/30/02 12:48PM >>>
> The things that I would have really appreciated
> at that
> time which I found difficult to find were general OOP 'good
> behaviours'.  for example
> maybe pointers on when one benifits from creating classes, when one
> benefits from
> creating a function outside a class as opposed to a method inside a
> class.
> <<snip>>
>
> I agree with Isaac on this one.  I am having a hard time grasping
> the object oriented "mindset", or what have you.  Perhaps it is
> not something that can be learned from a single tutorial, but
> maybe there are some conceptual things that could point us OOP
> newbies in the right direction.
>
> Christian
>
> +-------------------------------------------------+
> Christian Wyglendowski
> PC Support Specialist
> Information Technology
> Greenville College
> cwyglendowski@greenville.edu
> 618-664-7073
> +-------------------------------------------------+
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>