Ideas:chad3f:RPFramework: Difference between revisions
imported>Chad3f No edit summary |
imported>Chad3f No edit summary |
||
| Line 1: | Line 1: | ||
| ⚫ | |||
The current RPClass definition initialization model as-used is prone to problems and higher maintanance than should be needed. The current form would be coded similar to: |
|||
class SomeClass { |
|||
| ⚫ | |||
public static void generateRPClass() { |
|||
RPClass rpclass = new RPClass("some"); |
|||
rpclass.add("foo", RPClass.STRING); |
|||
} |
|||
} |
|||
class OtherClass { |
|||
public static void generateRPClass() { |
|||
RPClass rpclass = new RPClass("other"); |
|||
rpclass.isA("some"); |
|||
rpclass.add("bar", RPClass.STRING); |
|||
} |
|||
} |
|||
class MainClass { |
|||
void initFunction() { |
|||
SomeClass.generateRPClass(); |
|||
OtherClass.generateRPClass(); |
|||
} |
|||
} |
|||
This has the following problems/short-comings: |
|||
- It requires the generate methods to be explicitly called from some initialization code. The was an actual stendhal problem were several generateRPClass() methods were defined, but never called. |
|||
- The generate methods have to be called in the proper order. This requires the initialization code to know the implementation details (at least the class tree) of the RPClass's that it's configuring. As a result, unnecessary code-coupling is formed. If it is done wrong, or the heirarcy changes after the fact and nobody thinks to check those fragile dependancies, it could break. |
|||
- The parent RPClass is assigned after creation [via isA()], so there's the chance it could be missed. Or worse yet, called twice with different parents (that could have some nasty unexpected effects). |
|||
- The assigned parent is typically assigned by name, rather than object, which can make it prone to spelling errors. If you're lucky, it will throw an exception, if not a hard to track problem may arise. Also passing the name means a common base class has to be resolved several times. |
|||
''TBW'' |
|||
Revision as of 02:05, 31 May 2007
RPClass Initlialization
The current RPClass definition initialization model as-used is prone to problems and higher maintanance than should be needed. The current form would be coded similar to:
class SomeClass {
public static void generateRPClass() {
RPClass rpclass = new RPClass("some");
rpclass.add("foo", RPClass.STRING);
}
}
class OtherClass {
public static void generateRPClass() {
RPClass rpclass = new RPClass("other");
rpclass.isA("some");
rpclass.add("bar", RPClass.STRING);
}
}
class MainClass {
void initFunction() {
SomeClass.generateRPClass();
OtherClass.generateRPClass();
}
}
This has the following problems/short-comings:
- It requires the generate methods to be explicitly called from some initialization code. The was an actual stendhal problem were several generateRPClass() methods were defined, but never called.
- The generate methods have to be called in the proper order. This requires the initialization code to know the implementation details (at least the class tree) of the RPClass's that it's configuring. As a result, unnecessary code-coupling is formed. If it is done wrong, or the heirarcy changes after the fact and nobody thinks to check those fragile dependancies, it could break.
- The parent RPClass is assigned after creation [via isA()], so there's the chance it could be missed. Or worse yet, called twice with different parents (that could have some nasty unexpected effects).
- The assigned parent is typically assigned by name, rather than object, which can make it prone to spelling errors. If you're lucky, it will throw an exception, if not a hard to track problem may arise. Also passing the name means a common base class has to be resolved several times.
Message Protocol
TBW