To use associative arrays violates the principles of OOP?

#1
[eluser]Giga[/eluser]
Hello everyone,
I am an university student who needs to develop a web application for a project in software engineering.

Having to respect the principles of OOP, I asked myself some questions:
Using MVC should be no independence between the levels ... but in many video tutorials (youtube) known as the use of associative arrays.
Let me explain:
Code:
class ControllerX extends controller
{....
function inserisciX()
{
$options['p_iva_f']=$_POST['p_iva_f'];                
$options['nome']= $_POST['nome'];
$options['indirizzo']=$_POST['indirizzo'];                        

$this->load->model('fornitore_model','',TRUE);
$id = $this->fornitore_model->aggi
ungi($options);
}
}            

class ModelX extends model
{....
function aggiungi($options=array())
{
      $this->load->database();
      $fornitore = array(  'p_iva_f'=>$options['p_iva_f'],'nome'=>$options['nome'],
                        indirizzo'=>$options['indirizzo']);
            
             $this->db->insert('fornitore',$fornitore);
             return $this->db->insert_id();
        }
}
Now if I change in the controller:
$options[‘p_iva_f’] in $options[‘p_iva_fornitore’]
I have to change even in the Model!
The independence between the layers is lost in this way ???!!!

So,I decided to create a class ( in library):
Code:
class Fornitore
{
... attributes
....methods
}
Now step away from control to model an object of that class! In your opinion is as good solution for a more OO? Or you have other solutions?

Thanks in advance


Messages In This Thread
To use associative arrays violates the principles of OOP? - by El Forum - 04-26-2010, 10:29 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.