Which design is better?
Posted
by Tattat
on Stack Overflow
See other posts from Stack Overflow
or by Tattat
Published on 2010-04-24T16:17:52Z
Indexed on
2010/04/24
16:53 UTC
Read the original article
Hit count: 425
subjective
|design
I have an "Enemy" object, that have many "gun" . Each "gun" can fire "bullet". Storing "gun" is using an array. when the "gun" is fired, the "bullet" will be created. And the enemy object will have an array to store the "bullet".
So, I am thinking about the fire method. I am think making a firebulletFromGun in the "enemy". It need have a parameter: "gun". while this method is called. The "enemy" 's bullet will be added in the Array.
Another design is writing the fire method in the "gun". The "enemy" use the "gun"'s fire method. And the "gun" will return a "bullet" object, and it will be added in the Array of "enemy".
Both method can work, but which way is better? or they are similar the same? plx drop ur ideas/suggestions. thz.
© Stack Overflow or respective owner