[crossfire] 2.0 object-type refactoring

Lalo Martins lalo.martins at gmail.com
Tue Oct 31 06:30:14 CST 2006


On Mon, 30 Oct 2006 07:16:47 -0700, Alex Schultz wrote:
> Well, the way I was thinking of doing it, would be to replace specific
> calls to apply, drop, etc as they are sprinkled throughout the code, and
> keep common code such as you say, in a "common" subdirectory of the
> types directory, and then have the callback called by ob_apply(), call
> something like ob_apply_common() at the start of it's code.
> IMHO, with this method, the best way to handle legacy non-separated
> logic would be to move that legacy logic to the "types/common"
> subdirectory, and set it up so ob_apply() and such will call that if it
> can't find a callback registered for the type.

for that matter...

if you're refactoring into a proper object system, why not go all the way
and do subclasses?  Create a "BASEOBJECT" type, put all the "common" code
as methods of this type, and then call that from the top of the
specialised methods just like you'd do "super.foo()" in other languages. 
That keeps the way open for you to decide that, in the future, you need
more than one level of inheritance -- eg a "BASEARMOR" type that the armor
subtypes inherit from.

best,
                                               Lalo Martins
--
      So many of our dreams at first seem impossible,
       then they seem improbable, and then, when we
       summon the will, they soon become inevitable.
--
personal:                              http://www.laranja.org/
technical:                    http://lalo.revisioncontrol.net/
GNU: never give up freedom                 http://www.gnu.org/





More information about the crossfire mailing list