I am rebuilding a website I run which provides tide tables. I am doing it with the Zend Framework and am attempting to make it as object oriented as possible. I have been thinking about the flow/process that will occur when a visitor requests a tide table from a location and how it returns.
I have come up with 2 different "types" of objects to use which will assist in this process. The first is basically a helper object that Zend Framework uses. The second is a data object (for lack of a better word) to encapsulate data that is passed between helpers. Here is a rough idea of the flow I am thinking about:
- RequestHandler
- Receives array for request from site controller or from api controller.
- Creates "data object" called QueryData and populates it with all information about the request.
- Passes QueryData object to LocationHandler.
- Returns the ResponseData object which was returned to it from the LocationHandler.
- LocationHandler
- Receives QueryData object from RequestHandler
- Does work finding location and creates a LocationData object to store it in.
- Passes both QueryData and LocationData objects to different helpers such as TideHandler or WeatherHandler which return specific data for the initial query.
- Returns an array of ResponseData objects which contains the responses returned to it from each of the specific helpers (TideHandler,WeatherHandler,etc)
- TideHandler
- Receives QueryData and LocationData objects from LocationHandler.
- Does work using data objects to find tide data. Creates a ResponseData object to store it in.
- Returns ResponseData to LocationHandler.
In doing everything this way I get a "plug and play" OOP approach that allows me to add to this much easier (I think?). Sorry for the long explanation leading up to my question...
The Question:
Is it common practice to encapsulate sets of data into an object (rather than an array) to be passed around to other objects which perform functions on it and send on new/modified objects? What are some other solutions or patterns that provide a similar level of functionality and flexibility?