[167] in Coldmud discussion meeting

root meeting help first previous next next in chain last in chain last

Encapsulation

daemon@ATHENA.MIT.EDU (Fri Mar 25 17:29:33 1994 )

From: rayn@q.crossaccess.com (Ray Nawara jr.)
To: coldstuff@MIT.EDU
Date: Fri, 25 Mar 1994 13:16:34 -0800 (PST)

It is true that one object shouldnt directly modify another objects variable, 
but shouldnt the first object be able to ask the other object to change its
variable? or rather, can an object change its own variables....           
     Looking at the colddark core, I didnt see any method to do this, and
also didnt see a server function to do this. (this is not in any way representative
of the existence of said functions, as I'm very new to both the server and the DB)
Should accessors exist which enable the data to be modified or viewed, and can
be called from other objects? the concept of protected data could be enabled
by placing a check in the accessor method if the var were to be private or protected, most likely.
The kind of accessor i was thinking of could be called as 
on object $bar
	.foo()    -> 1
	.foo(0)   -> TRUE   (im not sure on the return for this, as i only mostly
			     follow the way error handling works. the function
				should return an error code if there is an error
				with setting the var, like a permissions error for
				protected data, or a type error)
	.foo()    -> 0     (displays the new value of foo)

on object $baz
	$bar.foo() -> 1
	$bar.foo() -> ~perm     (object $baz doesnt have permission to modify prop foo)

the method could then be modified to return the appropriate information, such
as string substitution, etc (i belive this is already in existence) 
In the db, the parameter creation function could also create these accessors with
little difficulty, perhaps based on a given template, for the various return 
conversions.

Is this just totally wrong?

Ash