views:

156

answers:

3

I wrote a Scale9Bitmap class in AS3 and it requires the dev to set the BitmapData and a Rectangle for the scale9Grid. I'm wondered what is customary for the public get functions of both. Do I return a clone of each to make it free of hanging references, but not as memory-friendly? or do I leave that up to the dev and return the original instances?

A: 

I'm not familiar with ActionScript but in other languages, I'd prefer to have the choice. So leave it to the dev.

Techpriester
Agreed - leave it up to the dev.
RJ Owen
+1  A: 

Leave it up to the developer. The developer is able to clone it if required. However this is very error prone. Usually you would shoot for immutable state and return a clone. But this is a bad idea with AS3 as you have already mentioned.

Joa Ebert
A: 

I would remove all logic, that actualizes the displayed state, from the setter and move it to some update method and leave this just a reference to the object.

Forcing a clone with every get would be extremely unhandy, for example think of a simple size check or such..

poke