[Crossfire-wiki] [Crossfire DokuWiki] page added: user:rednaxela:refactor

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Wed Oct 4 12:09:32 CDT 2006


A page in your DokuWiki was added or changed. Here are the details:



Date        : 2006/10/04 12:09

Browser     : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

IP-Address  : 192.139.27.18

Hostname    : host18.cbe.ab.ca

Old Revision: none

New Revision: http://wiki.metalforge.net/doku.php/user:rednaxela:refactor

Edit Summary: created (rednaxela: not logged in)

User        : 



**This page is a draft document in my user namespace. Will move to the dev
_todo namespace when the draft is ready for public review**



----



====== Objec-type refactoring ======

===== Reason =====

Currently in the crossfire code, how objects behave is intertwined all thr
oughout the code, and this is in many ways a problem as it makes it diffic
ult to find code related to a type of object. It's current state also make
s it relatively difficult to add code for new object types. Though it will
 never be that easy to add object types, refactoring could improve this si
gnificantly. Also, refactoring this to seperate code for different object 
types, will make it easier to find current overloading of object attribute
s, making it easier to eventually refactor the overloading out.



===== Proposal =====

==== General Idea ====

  * Allow operations such as 'apply' to be specified in pointers in all of
 the following ways, however only the last being used in the refactorign i
tself:

    * By object

    * By archetype

    * By type number

  * Seperate object type specific code into seperate files.

==== Implimentation Details ====

=== Code organization ===

    * Use form of server/types/foo.c or server/types/foo/bar.c depending o
n if the object type requires multiple C files to be clean.

    * Code used by multiple distinct types, but is not generic to all obje
ct types should be put in server/types/common/ with a logical filename.

    * Doesn't necessarly mean one type number per file, due to cases such 
as different types of armor, where all behave the same but have different 
type numbers.

=== Function pointers ===

FIXME //planned but to be written//

===== Plan =====

==== To start ====

  * Begin refactoring some things to the new system.

  * Start with simple things such as moving the apply code for all types.

  * Convert things to function pointers as needed.

  * Aim for ~90% of type-specific code moved into the new system.

==== Policy ====

  * Commit refactoring changes frequently in very small chunks. As small c
hunks as possible while keeping the SVN code working is preferable.

  * Try to give a bit of notice before commiting refactoring changes, noti
ng specifically what refactoring changes you intend to commit.

  * Document what you refactor, when you refactor it, and it's form in the
 system

  * :?:Should we require unit tests to be written

==== Later ====

  * Clean up the refactoring.

  * Attempt to get the remaining type-specific code moved into the system.

==== Eventually... ====

  * Impliment some sort of [[dev_todo:unified_event_system|unified event s
ystem]] and integrate with this object-type seperation. Not a priority rig
ht now, but something to keep in mind for later.



===== More information =====

  * [[http://thread.gmane.org/gmane.games.crossfire.general/1928|Crossfire
 mailing list: Code restructuring]]





-- 

This mail was generated by DokuWiki at

http://wiki.metalforge.net/





More information about the crossfire-wiki mailing list