Mar. 14th, 2009
flyweight pattern, Java
Mar. 14th, 2009 09:33 pmThe 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...здесь такой изумительный паноптикум... может, действительно лучше бы было если бы в 91-м коммунистов вешали на столбах (как они того ожидали)? (нет, конечно, не лучше; было бы ещё хуже)