So I have to create an object design for this application, it is just problem for practicing.

You are building application that will load data from several different advertising systems and then store the data into database, so it will be possible to analyze them.

You need to take in mind that every advertising system has different structure of report: Different named columns, different order of columns, different date formats Also data from ad systems are in different data formats(JSON,CSV,XML),

Reports from each system contains different amount of columns, our application is interested only in some of them(in every system they have different name)

I wrote this, only thing that is missing is method for selecting only columns that I need. Is this good structure ? I am new o OOP.

class Report {

    protected $data = [];
    protected $dataTypes = [];

    public function loadReport($adSystem){ return $data}

    public function loadAllReports($adSystemCollection){ return $data}


class Decode{

    protected $data = [];
    protected $dataTypes = [];

    public function getType($data){ return $dataTypes};
    public function getAllTypes($data){ return $dataTypes};
    public function getColumns($data, $columns){ return $data}
    public function convertToString($data,$dataTypes){ return $data}

class Query{

    $databaseConnection = "";

    public function __construct(){
    //get database connection
     return void;

    public function save($data){ return null};
    public function loadData($key){ return $data};

class Collection 
    private $items = array();

    public function addItem($obj, $key = null) {

    public function deleteItem($key) {

    public function getItem($key) {

1 Answer 1


When it comes to analyzing the requirement/problem description and translating it into a decent and practical OOP design, the best approach is to identify the proper nouns and verbs in the given statement:

For example, here we have an advertisement system that has different reports. And each report has a different format and each report contains columns and date formats.

Then next step is to identify the relationships between them:

In your scenario, as each advertisement system aggregates different reports. So here we have aggregation (one to many relationship).

Study this tutorial here for more and precise details: OOAD Tutorial

Identify the "is a" and "has a" relationship between the classes so wherever you come across "is a" relationship you would need a sub class i.e. you have to inherit a child class from the base class. In your case, there is no need for it. The "has a" relationship indicates aggregation or composition. And this is what I can see in your scenario as it is stated: "Report has a format", "Report has a column".

For a more clear explanation, go through this example: Aggregation

And in the final step, you have to identify the attributes of each class. For instance, here you have the number of columns that I would recommend that you should be including in your Report class.

But at the end of the day it all depends upon the core requirement in your application how your OOP design should be like.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.