Skip to main content
4 events
when toggle format what by license comment
Oct 6, 2015 at 18:13 comment added Yttrill When you design a concept, it should ALWAYS be abstract. Never never never put data in such classes. The whole idea is to use derivation to isolate the abstract representation (by methods) from multiple possible concrete representations (none of which is ever known by name except at the point of construction).
Oct 6, 2015 at 15:01 comment added mattnewport @EmilyL. you don't need to abandon value types to get polymorphic behaviour. Type erasure techniques give you the best of both worlds. Performance would still be a concern if you have an interface at the granularity of individual pixel access however. In that case static polymorphism via templates could be the way to go.
Oct 6, 2015 at 12:46 comment added Emily L. Yes, this was my initial idea, I wanted the Image to behave like a value type. However this breaks down due to other design requirements. Polymorphy in particular. I have a ImageAny interface which provides generic access to any type of image and Image<pixelmode> template sub classes that inherits ImageAny to provide a concrete class. The user can choose to write their algorithm using ImageAny for easy code that handles all cases or cast to Image<pixelmode> for higher performance.
Oct 5, 2015 at 17:08 history answered mattnewport CC BY-SA 3.0