Item.Mass - should this be an abstract property? |
Tue, 07 February 2012 14:51 |
|
ekolis | | | Messages: 51
Registered: May 2006 Location: Cincinnati, OH, USA |
|
|
As I was looking through the code, I found that lots of things inherit from the Item class, which has a public Mass field. This includes fleets and fleet intel, which makes the field somewhat problematic. After all, the mass of a fleet is a computed value - the sum of the masses of all constituent ships. But this is never initialized, so fleets and fleet intel have zero mass! This is even handled inconsistently in the GUI: a fleet report shows its mass as zero, but the "my fleets" list shows the appropriate mass, so the calculation is being done - it's just being done inconsistently.
I think this could be solved by making Item's Mass field an abstract property instead. Then ships could implement it by checking their design, and designs could implement it by summing the masses of their components, and fleets could implement it by summing the masses of their ships.
If this causes performance issues, the values could always be lazy-loaded and cached, but I doubt this will be a problem to begin with.
Also, Item has a number of other public fields which I haven't looked into, but I suspect some of them might warrant similar refactoring.
Thoughts? Concerns?
Mr. Flibble says...
Game over, boys!Report message to a moderator
|
|
|