New answers tagged

3

Instantiating and collecting small, short-lived, temporary objects, is perfectly fine. It is what modern garbage collectors are good at. Modern (generational) garbage collectors are built on a couple of assumptions: most objects die young, most objects are small, most objects don't escape, most objects are immutable, older objects don't contain references ...


-1

Garbage collection can become a performance issue in games, and might require special approaches. However, before you are sure that garbage collection of temporary Location instances is problematic, you would waste your time by trying to limit the amount of instances: “Premature optimization is the root of all evil.” To decide whether you should go down ...


1

First option is much better for all the reasons manlio stated. Additionally, in that case you could also use Observer pattern so that when you call fruit->ChangeCoordinates(); you can increase the score from within that method. Just a thought...


2

The first option is probably faster. With the second one you have, at least, the additional memory allocation task. Anyway this is a good example of premature optimization: performance shouldn't be a concern for this kind of operation. The snake eats a fruit just occasionally. Between two meals there are a lot of other (complex) events that take place and ...


0

I think you should use directives for the DOM elements and controllers for interaction between these directives. DOM manipulation should only be done inside a directive. Fetching a text file could be done inside the controller, but it would be better if you did that through a service. Services can be used for reusable business logic/fetching data. You ...


8

Whenever two or more threads need to change the same object and potentially at the same time, you need to ensure that the object remains in a consistent state making it synchronized. Apparently, it's not only about the object, but also its containing object, because you mention "if the user made a change to an object while the tick was deleting it". ...



Top 50 recent answers are included