【发布时间】:2010-05-02 05:25:09
【问题描述】:
我有一个名为 BitmapZone 的 Bitmap 类的包装类。
假设我们有一个 WIDTH x HEIGHT 位图图片,这个包装类应该用于允许我发送到其他方法/类本身而不是原始位图。然后我可以更好地控制用户可以或不允许对图片做什么(而且我不必多次复制位图来为每个方法/类发送)。
我的问题是:知道所有的 BitmapZone 都是从位图创建的,你觉得更喜欢什么?
构造函数语法:类似
BitmapZone bitmapZone = new BitmapZone(originalBitmap, x, y, width, height);
工厂方法模式:
BitmapZone bitmapZone = BitmapZone.From(originalBitmap, x , y, width, height);
工厂方法模式:
BitmapZone bitmapZone = BitmapZone.FromBitmap(originalBitmap, x, y, width, height);
其他?为什么?
谢谢
【问题讨论】:
标签: c# java oop constructor factory-pattern