[MUD-Dev] TECH:

Bruce Mitchener bruce at cubik.org
Thu Jul 25 08:20:52 CEST 2002


Britt A. Green wrote:

> A friend and I are working on a small MUD as a way to teach
> ourselves more Python. We're kind of stuck and could use some
> guidance from the more knowledgeable members of this mail list! :)

Depending on your other motivations and intentions, you might find
that that goal is better met by finding an existing mud in Python
and contributing to that.  Maybe not though.

> Briefly, we have classes for rooms, items, players and
> whatnot. What's the best way to update these things? If a player
> picks up an item, should that code be in the player object? A
> function callable my main that's outside of any object?

Something that I find useful in this regard is the Law of Demeter:

   http://www.ccs.neu.edu/home/lieber/LoD.html

   "The Law of Demeter was originally formulated as a style rule
    for designing object-oriented systems. "Only talk to your
    immediate friends" is the motto. The style rule was invented
    at Northeastern University in the fall of 1987 by Ian Holland.

    A more general formulation of the Law of Demeter is: Each unit
    should have only limited knowledge about other units: only
    units "closely" related to the current unit. Or: Each unit
    should only talk to its friends; Don't talk to strangers.

    The main motivation for the Law of Demeter is to control
    information overload; we can only keep a limited set of
    items in short-term memory. The definition of "closely
    related" is intentionally left vague so that it can be
    adapted to particular circumstances.

    In the application of LoD to object-oriented design and
    programming we have:

       unit = method f

       closely related = methods of class of this/self of f and
          other argument classes of f and methods of immediate
          part classes of class of f (classes that are return
          types of methods of class of this/self) and methods
          of classes of objects that are created in f.

    Rumbaugh summarizes the Law of Demeter as: A method should have
    limited knowledge of an object model."

There are other and longer explanations on the site linked above
... and really, it is a pretty basic underpinning of OO design.

To get back to your question, the code could live on both.  Some
code will live on the user for handling the actions of the user,
which will call code that is on the item being picked up to handle
manipulation and movement of the item.  That code on the item will,
in turn, call call on the user to update the user's inventory and so
on.

> Hope what I'm asking isn't too confusing. Thanks!

Not at all and good luck!

  - Bruce

_______________________________________________
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