Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 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. Commented Oct 6, 2015 at 12:46
  • @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. Commented Oct 6, 2015 at 15:01
  • 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). Commented Oct 6, 2015 at 18:13