Note that there are some explanatory texts on larger screens.

plurals
  1. POData Encapsulation and Data Flow in PHP
    primarykey
    data
    text
    <p>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.</p> <p>I have come up with 2 different "types" of objects to use which will assist in this process. The first is basically a <em>helper</em> object that Zend Framework uses. The second is a <em>data</em> 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:</p> <ul> <li><strong>RequestHandler</strong> <ul> <li>Receives array for request from site controller or from api controller.</li> <li>Creates "data object" called <strong>QueryData</strong> and populates it with all information about the request.</li> <li>Passes <strong>QueryData</strong> object to <strong>LocationHandler</strong>.</li> <li>Returns the <strong>ResponseData</strong> object which was returned to it from the <strong>LocationHandler</strong>.</li> </ul></li> <li><strong>LocationHandler</strong> <ul> <li>Receives <strong>QueryData</strong> object from <strong>RequestHandler</strong></li> <li>Does work finding location and creates a <strong>LocationData</strong> object to store it in.</li> <li>Passes both <strong>QueryData</strong> and <strong>LocationData</strong> objects to different helpers such as <strong>TideHandler</strong> or <strong>WeatherHandler</strong> which return specific data for the initial query.</li> <li>Returns an array of <strong>ResponseData</strong> objects which contains the responses returned to it from each of the specific helpers (TideHandler,WeatherHandler,etc)</li> </ul></li> <li><strong>TideHandler</strong> <ul> <li>Receives <strong>QueryData</strong> and <strong>LocationData</strong> objects from <strong>LocationHandler</strong>.</li> <li>Does work using data objects to find tide data. Creates a <strong>ResponseData</strong> object to store it in.</li> <li>Returns <strong>ResponseData</strong> to <strong>LocationHandler</strong>.</li> </ul></li> </ul> <p>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...</p> <h2><strong>The Question:</strong></h2> <p>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?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload