java - Prefered way to reference super classes (typed languages) -
this problem comes quite bit actually. take instance model view. have 2 objects. simulation object , render object.
the class objectrsim (object, designated render sim) like:
class objectrssim { var simobject:objectsim; } objectrsim, uses properties/invalidation of objectsim.
there objects inherit objectrsim , objectsim:
posobjectrsim , posobjectsim (positional objects..)
class posobjectrsim extends objectrsim { var possimobject:posobjectsim; } or...
class objectrsim { var simobject:dynamic; //dynamic untyped type haxe, compiler not check calls dynamic object. } should have reference each type in inheritance hierarchy of objectsim in objectrsim hierarchy classes, or should use simobject:dynamic?
it totally wrong use dynamic case. it's slow(for every haxe target except javascript guess), not inlined, , used interacting underlying platform or working serialization(yaml, json etc.).
talking solving problem...
if there aren't thousands of objects planned, i'd field lower-level class object. it's not clearest way oop perspective, results in simpler , clearer code me.
casting option(i don't like).
parameterization best way handle that, i'm not sure if have type restricted parameterization in haxe.
Comments
Post a Comment