View Full Version : OOP Design Question

27 Nov 2007, 7:55 AM
First off, I love EXT. I was using FlashMX (just before flex came around) and used to think the V2 Components in Flash were hot. EXT is way hoter (graphically) and has a more flexible API.

My question today is not EXT Specifc, its an application design question.

My application is kinda like the form builder app. It has a canvas where users can design a layout by dragging and dropping 'elements' from their pallete and creating new elements. There could be over 200-300 elements. Each element needs to store its x/yposition and also all of its properties which vary from object to object.

My options are to use the factory pattern to generate an instance for each element when the editor loads. This could mean 200-300 objects instantiated. Most of the methods would be shared and on the objects prototype, and I beleive that would keep memory usage down rigth?

My alternative is to use the flyweight pattern and have one master class storing an array of objects (not actual class objects, but data describing the elements properties).

Personally I am leaning towards having a class instance for each object as opposed to the flyweight pattern, but I am wondering if this is going to be to memory intensive or if it is overkill.

I am new to design patterns and OOP, if I hadn't already made that obvious :)