I’m trying to understand the design decision taken when the .NET framework creators designed the System.Drawing.Image class. It is abstract, and yet a lot of the heavy lifting is done directly with the Image class. It also defines two methods for directly creating an Image object, Image.FromFile and Image.FromStream.
I thought the purpose of an abstract class is to faciliate a way to define functionality that should only be inherited by child classes. It seems weird that an abstract class would actually define methods that return an instance of the abstract class.
Why was it implemeted this way?
This is an instance of the factory pattern. This pattern is prevalent throughout the .NET framework, another example is System.Net.WebRequest.Create, which can return a different subclass depending on the specified Uri.
The reasoning for the pattern is that a different subclass of Image, such as Bitmap, can be created depending on the image type.