Your browser must have JavaScript enabled in order to view this page.
 >  >
 
Welcome Guest#1830 Login/register    Go to Bottom
Go to Top
 > Installation - Windows   Inner workings of DutchPIPE >
A world populated with objects

A world populated with objects

PERSISTENT OBJECTS WHICH CAN CONTAIN OTHER OBJECTS

An "object" is a programming principle, where you have little pockets of functionality and information depicting stuff like users, pages or a database api, which operate on themselves and on eachother.

Web servers like Apache destroy served client requests, all objects are destroyed after a page is served, and this made object oriented programming rather limited before, serving mainly as a way to organize code. There are web servers and many alternatives that do allow a persistent state, although it's usually in single user mode, and objects float "in nowhere". Most of them only show updates with each page view, or require something like Java on the client-side.

What gives DutchPIPE the feel and functionality which makes it rise above the normal concept of a collection of persistent objects, is the concept of one world for everyone, and the concept of objects being able to contain objects and be in another object. This is what makes it an abstracted world, and this allows for a lot of "auto-magic" to arise for developers. This world concept is much like the LPMud (Multi-user Dungeons/Domains/Dimensions by Lars Pensj) concept I toyed with in the early nineties, and still appeals to me as one of the most natural and powerful building concepts.


Objects, objects, objects...

Our world concept is based on just three very important functions which are available to all objects:

  • ob->getEnvironment() returns the object which contains 'ob'
  • ob->getInventory() returns an array of objects that 'ob' contains
  • ob->moveObject(ob2) moves 'ob' into 'ob2'

(Internally, PHP doesn't know about the concept of objects containing other objects, and this feature is purely simulated. These functions operate on a global array which maps each object to the object in which it is contained, its "environment".)

User objects are moved into page objects, that is, the page must be seen as the environment or location of the user. Other objects, such as a product object, can then be put in this location, and then the user can pick it up to "carry" the object, because it is in the same environment.

Each object inherits a standard object class which defines common features, which among others simulate our world concept. The three core methods listed to the left are among these. Others are methods to set the object's appearance and add actions (see below) to it. Extending the standard object class, other standard object classes, such as the user, page or drink class, define our building tools.

Another important concept is that chains of events are triggered by objects calling eachothers' methods. These chains of events can be triggered by user actions, or running processes. Each object can define actions, which can become available to a user when the object is either a) the user itself, b) in the user's inventory, b) its environment, c) in the user's environment.

For instance, a page can define the action "print", which becomes available when the user enters the page, because the user object is moved into it. The object "beer" defines the action "drink", which, if the beer is "dropped" in a page, becomes available when the user enters the page. When you try to drink it, it will then give a message you need to pick up the beer, if you didn't do so already by natural reflex. The object enters your inventory, and the drink action becomes available again. The method in the object which is linked to the drink action and called when you attempt to drink it, now sees by a call to getEnvironment() it is indeed picked up. It calls methods in itself to alter its state into "an empty beer glass". It calls methods in the user object and in its environment and other user objects present on the page to communicate a message or animation which depicts the drinking (this is an example of how users get messages and such from stuff triggered by others). If the page depicts a bar, that object could then decide to offer you a new beer object.

Popular actions are defined by the user object itself, for instance the actions "get" and "drop" are not defined by each object for themselves, but by the user object, to operate on other objects.


 > Installation - Windows   Inner workings of DutchPIPE >

Documentation generated on Mon, 03 Sep 2007 22:17:53 +0200 by phpDocumentor 1.3.0RC6

Click me!
Guest#1830
 
 
 
  Go to Top
 
 
Input Field OptionsClose Input Field Go to Top
 
Legal Notices | Copyright © 2006, 2007 Lennert Stock. All rights reserved. Last update: Mon Sep 03 2007, 21:50 CET.