The current design of the Image class doesn't make it easily extendable so that users can define their actions and additional fields in the upload response. This also limits class extensions for use cases where custom data and actions must be implemented.
Cause
The Image class was first designed with types fixed for the actions and upload response data, which is a very concrete design, and it limited the flexibility with different kinds of requirements. The approach taken in designing thus becomes relatively narrow and does not allow an extension of the user's custom properties during the creation of Image object.
Solution
Generic types should be used to re-implement the Image class to fix this problem. The definition of the class should change into class ImageTool<CustomActions = {}, AdditionalUploadResponse = {}>, such that while the object of it is created, users can provide their custom actions and additional upload response types. This makes the Image class flexible and more usable and leaves the ability to respond to almost any scenario and requirements.
Problem
The current design of the
Image
class doesn't make it easily extendable so that users can define their actions and additional fields in the upload response. This also limits class extensions for use cases where custom data and actions must be implemented.Cause
The
Image
class was first designed with types fixed for the actions and upload response data, which is a very concrete design, and it limited the flexibility with different kinds of requirements. The approach taken in designing thus becomes relatively narrow and does not allow an extension of the user's custom properties during the creation ofImage
object.Solution
Generic types should be used to re-implement the
Image
class to fix this problem. The definition of the class should change into classImageTool<CustomActions = {}, AdditionalUploadResponse = {}>
, such that while the object of it is created, users can provide their custom actions and additional upload response types. This makes theImage
class flexible and more usable and leaves the ability to respond to almost any scenario and requirements.