[MUD-Dev] SMAUG Code (was Personality Types)

Alistair Milne krug at krug.org.uk
Wed Aug 22 09:01:54 CEST 2001


> -----Original Message-----
> From: Kwon Ekstrom

> I've never worked with Cold so I don't know how their object
> heirarchy is, but OOP is meant to save time, code, and allow
> better understanding by associating method calls with the data
> structure they work with.  I'll admin I've seen several different
> OO muds with a terrible object heirarchy, but with OOP planning
> (something mud development often lacks) is even more important.

You're implying here that the best Object Oriented approach is to
use the equivalent of Get() and Set() methods.  In my experience,
the better designed class is the one that has methods for the roles
that the object will play, rather than simply direct access
functions to the data.  For example when a player types 'look' in a
room, rather than having methods in the Room class for
GetLongDescription(), GetExits(), GetContainedThings(), etcetera, I
would give it a DescribeYourself(ch) method, which takes a player's
object as an argument, interrogates it to see how the text should be
formatted, then sends along the relevant room description.  This
approach is also portable to other classes, so they can also have a
DescribeYourself() method, and you have a nice simple consistent
interface.  Do the class-specific work inside that class, not at the
Player's end:

    void Player::look( Thing& subject )
    {
        subject.DescribeYourself( *this );
    }

Alistair

_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list