Traits, r

Greg McCarroll greg at mccarroll.org.uk
Sun Feb 10 16:30:33 GMT 2008


On Fri, Feb 08, 2008 at 11:11:55AM -0800, John Costello wrote:
> On Fri, 8 Feb 2008, Greg McCarroll wrote:
> > On Fri, Feb 08, 2008 at 12:28:21PM +0000, David Cantrell wrote:
> > > 
> > > Pronouncing it as "is a" works well when you're explaining OO to
> > > newbies in terms of how physical objects 
> > 
> > This is why everyone should learn OO via MUD programming, sure it'll
> 
> I sort of agree, since my first exposure to OO was through MUD programming 
> (LPC).  It's fairly simple, even if it does teach bad C habits. 
>
> chess pieces as examples, going on similar lines to MUD programming.  
>

The one that I always liked was the Container class. Everything inherited
from it,

	Thing		What it carried typically

	Monster		Treasure
	Player		His inventory
	Player		His rucksack
	Rucksack	More inventory
	Room		Players
	Wand		Spell Charges
	World		Rooms (IIRC, if you destroyed a container you were in
			you moved up to its holding container)


But it wasn't the above that really helped me think about OO in new ways, it
was the combination of the imaginative/inventiveness of roleplaying games
which are really what MUDs are (sort of) combined with it. At a certain point
(sorry this is getting D&Dish) you take an idea like a 'bag of holding'[1] and you
can realise you can add a function to it that allows entry into it and also in code
give it the Room inheritance. So you have something like

	Greg> open bag (Container::Bag code)
	Greg> go bag (Custom Bag of H. code based on Room code)
	Other players see: Greg exits bag.
                         : The bag drops to the ground.
	
And it's at this stage in a typical MUD the other players in the room would take
the bag and close it leaving Greg in a room container trapped:-).

The thing was I don't think there was anything particularly special here, but I
just think it was a quality of teaching/learning which because I was 
using my imagination, I just got the OO concept really well and can still hopefully
see the more boring classes like reports, accounts, warehouses, etc. more
creatively.

I'm afraid this is one of those posts that people who like formal learning will
hate and those that like play learning will maybe love.

G.

[1] a magic item in D&D games where the bag leads onto a miniature dimension so
you can store huge amounts of things in it.


More information about the london.pm mailing list