I have an abstract class called Node
. It contains a constructor that takes a row from my database, and instantiates basic information. All pieces of content on my website extend this class - Person
, Event
, Project
, etc.
3 of these extending classes are special - when they are constructed, in addition to pulling values from the database, they also need to query a web-service; if the web-service provides values that are different from the ones given in the DB, they need to save to the DB.
In a multiple-inheritance capable language, this would be fairly simple; any one of these classes would extend both Node
, and APIData
, or something like that. Without MI, I'm not sure how to handle this. Using an interface would not be helpful, as that provides no concrete implementations.
The decorator pattern is sometimes recommended as a substitue for some features of MI, but I don't have enough experience to determine if this is the appropriate choice. Any suggestions?