I want to know if there are any disadvantages/ drawbacks of using value objects in initializing an object, for example:
public class MonsterVO
{
public var tenticles : Boolean;
public var growl : GrowlType;
public var damage : int;
public var health : int;
}
public class Monster
{
private var tenticles : Boolean;
private var growl : GrowlType;
private var damage : int;
private var health : int;
public function Monster(monsterData : MonsterVO)
{
tenticles = monsterData.tenticles;
growl = monsterData.growl.clone();
damage = monsterData.damage;
health = monsterData.health;
}
}
If you plan to use and initialize your
Monsterdomain object the only way (from DTOMonsterVO) — there is no problem. But how you can be sure if there won’t any other usages in the future? You can’t overload constructor in ActionScript (like in Java). What if you’ll need to create a clone? You’ll have to create some fakeMonsterVOfor that 🙁I think it is better to create some Factory Method to solve your problem.