flyweight pattern, Java
Mar. 14th, 2009 09:33 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
The problem is this. We have
Now, there seems to be no way to have a method like
interface Entity {...}
; and we have, say, class EntityCollection {...}
. An entity has several attributes, but we store the attributes somewhere in a differnt way in EntityCollection, e.g.
String[] firstNamesand
String[] lastNames, something like that.
Now, there seems to be no way to have a method like
getEntity(int i)
without actually instantiating something or actually having an instance. Looks like a subtle defect to me: eventually all we need to do is use some methods from the virtual instance of Entity
, and, generally speaking, we would not need any memory for that. I mean, in c with macros we could do this dirty trick, but with Java... everything seems to be so materialistic...