Better to use constructor or method factory pattern?
Posted
by devoured elysium
on Stack Overflow
See other posts from Stack Overflow
or by devoured elysium
Published on 2010-05-02T05:25:09Z
Indexed on
2010/05/02
5:27 UTC
Read the original article
Hit count: 299
I have a wrapper class for the Bitmap .NET class called BitmapZone.
Assuming we have a WIDTH x HEIGHT bitmap picture, this wrapper class should serve the purpose of allowing me to send to other methods/classes itself instead of the original bitmap. I can then better control what the user is or not allowed to do with the picture (and I don't have to copy the bitmap lots of times to send for each method/class).
My question is: knowing that all BitmapZone's are created from a Bitmap, what do you find preferrable?
Constructor syntax: something like
BitmapZone bitmapZone = new BitmapZone(originalBitmap, x, y, width, height);
Factory Method Pattern:
BitmapZone bitmapZone = BitmapZone.From(originalBitmap, x , y, width, height);
Factory Method Pattern:
BitmapZone bitmapZone = BitmapZone.FromBitmap(originalBitmap, x, y, width, height);
Other? Why?
Thanks
© Stack Overflow or respective owner