Reputation: 840
I want to make a method for creating an arbitrary amount of Player-objects (stored in an ArrayList in PlayLogic). For now I've decided on just creating 2 Player-objects. I'm hardcoding this in PlayActivity by calling createPlayers(2)
, so the implementation of this.. is it better to pass the parameter to Play which then passes the parameter to PlayLogic which creates 2 Player-objects.. or is it better if I directly call PlayLogic from PlayActivity?
I want my design to reflect efficient design (so I want as few relations as possible, not sure if this is the correct UML-term..).
Upvotes: 0
Views: 115
Reputation: 24316
There will be a trivial amount of overhead that comes about from having an extra layer in the process. This overhead is not enough to dictate muddying a design (improper abstraction). The reason why there is extra overhead is because you are asking someone else for information in the multi-layered approach. For instance:
2 People can communicate with each other faster than 3 people can with the same information, follow the example below:
A -> B (what is 2+2)
B-> A (4)
VICE
A->B (what is 2+2)
B->C (what is 2+2)
C->B (4)
B->A(4)
Further you talk of performance, but have opted to use an ArrayList
, it could be the case that this data structure is incorrect, we would need more information about the underlying object model and the operations that will be performed most often during execution.
Upvotes: 2