How IEnumeberable might get you in trouble

Quite often I see a bug where a certain Factory method creates an IEnumeberable of objects.

While initially looking at the code you might not notice it, but that sort of code might lead to excessive creation of instances because of multiple enumeration of objects causing the factory method to create more objects that you expect.

For example let examine this bit of innocent looking code:
Continue reading “How IEnumeberable might get you in trouble”

Blog at WordPress.com.

Up ↑