Ideas:chad3f:RPFramework: Difference between revisions
Content deleted Content added
imported>Chad3f |
imported>Chad3f |
||
| (62 intermediate revisions by the same user not shown) | |||
Line 39:
This has the following problems/short-comings:
=== Proposed Replacement ===
Using static RPClass
The replacement code would look like:
Line 55:
class SomeClass extends RPObject {
public static final RPClass RPCLASS = createRPClass();
private static RPClass createRPClass() {
RPClass rpclass = new RPClass("some");
Line 65:
class OtherClass extends SomeClass {
public static final RPClass RPCLASS = createRPClass();
private static RPClass createRPClass() {
RPClass rpclass = new RPClass(SomeClass.RPCLASS, "other");
Line 72:
}
}
class AnotherClass extends SomeClass {
public static final RPClass RPCLASS = createRPClass();
private static RPClass createRPClass() {
RPClass rpclass = new RPClass(SomeClass.RPCLASS, "another");
Line 90:
In this code, when one of these java classes is loaded, the static initializer will automatically call it's createRPClass() method. If the class has a super-RPClass [such as OtherClass.createRPClass() uses], before the reference to SomeClass.RPCLASS is used, the JVM will have loaded SomeClass and called it's createRPClass().
If the parent RPClass is only assignable during the constructor of sub-classes [i.e. normal use of isA() goes away], then it will be more obvious that the parent has been omitted. Of course, someone could always call the RPClass constructor with no parent argument, and still forget the super, unless the only constructor(s) available required the parent, in which case the
Benefits:
----
== Message Protocol ==
Line 107 ⟶ 110:
''TBW''
----
[[Ideas:chad3f|Back to Ideas]]
| |||