I'm working on some code, and I'm wondering if I should make a seperate TVector class, or include it as part of a TEntity class. That is should I do it like this....
...or should I do it like this....
With the first method I will need to refer to things like player.t.x and particle.previous.t.x. While with the second I can just do player.x or particle.prveious.x, but it means that I will have some extra stuff (rotation and scale, plus some methods for those) in the class those times I only need a vector.
I've actually changed my code back and forth between the two a couple of times, and can't seem to make up my mind which is the better way to go. :)
Ragnar
p.s. Thanks for the link on the Law of Demeter, the first method breaks that...but only in a way that I don't think would be problematic as the TVector class would be a very central part of the code.
Type TVector Field x:Float Field y:Float End Type Type TEntity Field t:TVector Field r:Float Field s:TVector End Type
...or should I do it like this....
Type TEntity Field x:Float Field y:Float Field r:Float Field sx:Float Field sy:Float End Type
With the first method I will need to refer to things like player.t.x and particle.previous.t.x. While with the second I can just do player.x or particle.prveious.x, but it means that I will have some extra stuff (rotation and scale, plus some methods for those) in the class those times I only need a vector.
I've actually changed my code back and forth between the two a couple of times, and can't seem to make up my mind which is the better way to go. :)
Ragnar
p.s. Thanks for the link on the Law of Demeter, the first method breaks that...but only in a way that I don't think would be problematic as the TVector class would be a very central part of the code.