php - Polymorphic Domain Objects Based On Data Mapper -


I have a basic domain object, such as a person or a campaign or event that is represented by a table in the database. However, I have more complex versions of these objects, such as PersonCampaign or PersonEvent or even CampaignEvent, which can theoretically raise one object.

However, it becomes complicated for a number of reasons, because PHP does not support multiple legacy (for example, PersonEvent expands the person or event) and also because some domain objects are actually There are factory objects with different properties and functionality (for example the event is actually the type of event, such as email, call, and fax by fax).

Based on the simplest solution I can see, which data is returned from the data access layer, the object should be the actual form of change.

Is anyone suggesting a better way to handle this? Or can it change properties and behavior based on what is currently available from the Data Access Layer, which is right to create an integrated domain object?

The person class can work like this:

  Get_events () add_event ($ event) remove_event ($ event)  

And event class

  get_person () set_person ($ person) unset_person () / 

(Badly believe this data mapper Will be bothered or wonted)

Data Mapper exactly


Comments